问题描述
所以我认为我已经尽力了.我试图从Excel工作表中的单选按钮和复选框中获取值.我的第一种方法是使用Excel数据读取器: http://exceldatareader.codeplex.com/.带有复选框的单元格为空.
So i think ive tried everything now. Im trying to get the values from radiobuttons and checkboxes from an excel sheet. My first approach was to use the Excel Data Reader: http://exceldatareader.codeplex.com/. The cells with checkboxes render empty.
如果我使用OLEDB也是一样;
Same thing if i use OLEDB;
string filename = @"C:\\" + "uploads\\SmartAuditSheet.xls";
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
DataSet myDataSet = new DataSet();
dataAdapter.Fill(myDataSet, "BookInfo");
DataTable dataTable = myDataSet.Tables["BookInfo"];
gv.DataSource = myDataSet;
gv.DataBind();
请帮助.
推荐答案
我建议为此使用一些第三方库-有一些第三方库(免费和商业版)不需要安装Excel:
I would recommend using some 3rd-party library for that - there are several out there (free and commercial) that do NOT require Excel being installed:
-
OpenXML 2.0 (来自MS的免费库)可用于读取/修改.xlsx的内容,因此您可以根据需要进行操作
OpenXML 2.0 (free library from MS) can be used to read/modify the content of an .xlsx so you can do with it what you want
EPPlus (免费库)可用于XLSX
EPPlus (free library) works with XLSX
一些(商业)第三方库带有网格控件,使您可以在应用程序(无论是Winforms/WPF/ASP)中使用excel文件(大多数文件不仅可以XLSX,而且还可以XLS)做更多的事情. NET ...),例如 SpreadsheetGear , Aspose.Cells , Flexcel 等.
some (commercial) 3rd-party libraries come with grid controls allowing you to do much more with excel files (most can do not only XLSX but XLS too) in your application (be it Winforms/WPF/ASP.NET...) like SpreadsheetGear, Aspose.Cells, Flexcel etc.
这篇关于读取Excel文件->获取复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!