Free Support Forum - aspose.com

Reading an Excel file data without opening it

HI

we are using the Aspose.excel version 3.5.2.0

Got a requirement to read through the excel sheet and persist the data into a datastore

For this we want to read through the excel without opening the file.

the method excel.open() ... opens the excel file .

Since we cant upgrade this version, we are looking for the methods available in this version .

Has any one got through any method suiting this purpose?

cheers

babu

Hi Babu,

Since you are using some older version of the component and I am not sure about it. I think you should open the Excel object first which is compulsory (alternatatively, you may use Excel.LoadData method which is a bit faster than Open method), then get your desired worksheet in the workbook, you may extract your desired data either through cell by cell or use methods i.e., Cells.ExportDataTable() method (if available) or Cells.ExportArray() method to fill a datatable or an object array. Now you can update your datasource with your desired data based on datatable or array.

Thank you.

Amjad , Thanks for the reply

But the problem tat we will be faced with is, the excel sheet will get opened at the client side, which is not at all intended and we have to manually close that excel sheet

When the only thing intended to be done is read the excel data, these methods are infact getting the excel file opened at the client side which is to be avoided completely.

What is the workaround for this?

Thanks

Babu

Hi Babu,

I am not very clear what you have described. Well, Excel.Open and Excel.LoadData only loads the excel file with data / objects into memory not physically displays into MS Excel. When you save the excel file using the following method, the resultant file would be opened into MS Excel / browser:

e.g..,

excel.Save("MyBook1.xls", FileFormatType.Default, Aspose.Cells.SaveType.OpenInBrowser, this.Response);

Thank you.