我正在使用 c# 在 asp.net 中解析上传的 excel 文件(xlsx)。我正在使用以下代码(简化):
string connString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";");
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connString);
DataSet ds = new DataSet();
adapter.Fill(ds);
adapter.Dispose();
DataTable dt = ds.Tables[0];
var rows = from p in dt.AsEnumerable() select new { desc = p[2] };
这很好用,但如果单元格中的字符超过 255 个,它将被截断。知道我做错了什么吗?谢谢你。
编辑:查看 excel 表格时,它显示的字符数超过 255 个,所以我不相信表格本身是有限的。