单元格值被截断,而excel上传



我使用以下代码excel上传

 OleDbConnection sSourceConnection;
            string properties = "Excel 8.0; HDR=NO; IMEX=1;";//properties set for connection to excel
            string sSourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + filePath + ";Extended Properties="" + properties + """;
            sSourceConnection = new OleDbConnection(sSourceConstr);//creating the OLEDB connection
            try
            {
                //select statement to select data from the first excel sheet
                string sql = string.Format("Select * FROM [{0}]", "Sheet1$");
                //commands to fill the dataset with excel data
                OleDbDataAdapter excelAdapter = new OleDbDataAdapter();
                OleDbCommand command = new OleDbCommand(sql, sSourceConnection);
                sSourceConnection.Open();
                excelAdapter.SelectCommand = command;
                excelAdapter.Fill(dSet, EXCEL_DATA);

我必须上传大约300条记录。其中一列有一些文本注释。注释长度从10个字符到1000个字符不等。但是长度超过255的所有评论都在那列中被截断。

我已经使用了这篇文章Excel单元格值被OLEDB-provider截断来改变注册表设置,但它没有工作。

我也尝试了帖子中提到的所有方法。混合Excel数据类型:缺少数据,仍然没有工作

我使用的是ACE引擎,所以更新注册表的正确位置是

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice14.0Access Connectivity EngineEnginesExcelTypeGuessRowsHKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice14.0Access Connectivity EngineEnginesExcelTypeGuessRows

For Microsoft Office 2010-2013-2016/365

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice14.0Access Connectivity EngineEnginesExcel

更好的方法是扫描文本"TypeGuessRows",当你找到它时,结合Excel,将其值设置为0。我们在这里找到了另一个重要的位置

HKEY_LOCAL_MACHINE SOFTWAREMicrosoftOffice ClickToRunREGISTRY MACHINESoftware Wow6432Node Microsoft Office16.0Access Connectivity EngineEnginesExcel.

最新更新