Free Support Forum -

How to read browsed excel file


I came across your product through google. We needed a way to read and export excel data to sql server.

I found this article

Export Data from Worksheet

which works perfectly. I was just wondering how possible is it to allow users to browse for the excel file rather than accessing it through the c drive.

//Instantiating an Workbook object
Workbook workbook = new Workbook();

//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls",FileMode.Open);

//Opening the Excel file through the file stream

//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

//Exporting the contents of 7 rows and 2 columns starting from 1st cell to DataTable
DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0,0,7,2,true);

//Binding the DataTable with DataGrid
dataGrid1.DataSource = dataTable;============added by me

//Closing the file stream to free all resources

I am using the evaluation copy of the program - trying before buying.


It's very easy. Please put an OpenFileDialog instance in your winform application and add this line of code:

FileStream fstream = new FileStream(openFileDialog1.FileName, FileMode.Open);

sorry, i failed to mention that we are testing with webform


FileStream fstream = new FileStream(openFileDialog1.FileName, FileMode.Open);

You can try to put a HtmlInputFile control in your web page. And please try:


Thanks for the tip.

All i have to do is convince the boss to release the funds.