开发者

How do I use LinqToExcel to get the sheet names of an Excel file?

I am using LinqToExcel. I want to be able to get the names of all sheets in an Excel file and compare them with an input value from my html开发者_StackOverflow form such that when the input value does not match any of the names on the Excel sheet, the system throws an exception. How do I go about using LinqToExcel to do this?


The documentation says:

The GetWorksheetNames() method can be used to retrieve the list of worksheet names in a spreadsheet.

var excel = new ExcelQueryFactory("excelFileName");
var worksheetNames = excel.GetWorksheetNames();


using LinqToExcel;


filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/Excelfiles/"+filename));
var xl = new ExcelQueryFactory(Server.MapPath("~/Excelfiles/" + filename));
var worksheetNames = xl.GetWorksheetNames();           
DropDownList2.DataSource = worksheetNames;
DropDownList2.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜