I have to load excel file into sql server i use window application so i select filepath in textbox when click button using fileopendialogbox my problem is that i want ot provide list of开发者_如何学运维 sheets of file in combo box.
so user can select appropriate sheet to upload. Because it may possible that there are many sheets in file and tool doesn’t know which one to upload.
Something like:
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
Excel.Sheets sheets = theWorkbook.Worksheets;
list.Add (sheets);
}
精彩评论