Excel to text file conversion

Hi,

I am converting Excel file to text file using Aspose.Cells.dll for .net. If the excel book contains more than one sheet, the output text file contains the last sheets contents only. Please analyse this and let me know where I am doing mistake.

Workbook wb = null;

wb = new Workbook("excel file");

_workBook.Save(Text file path, SaveFormat.TabDelimited);

Thanks,

Dhivya

Hi,


Well, If you are saving an Excel file (having multiple sheets) to Text (Tab Delimited) file, you can only save the active worksheet as this is the limitation of Text (Tab Delimited) format. If you could manually do this in MS Excel, I mean open your Excel file into MS Excel and then save it as “Text (Tab Delimited)”, you find an error message in MS Excel, i.e.

The selected file type does not support workbooks that contains multiple sheets.

To save only the active sheet, click OK,
To save all sheets, save them individuality using a different file name or each…


Thanks for your understanding!

Thanks for your reply Amjad.

Is there any public API to extract full text from worksheets using Aspose.Cells.dll for .net.

Hi,


I am afraid there is no way as this is the limitation of MS Excel for text or tab delimited file format. As a workaround, you may try to copy all the worksheets data to a single worksheet and then save it as text or tab delimited file format.

Thank you.

Hi,

Please try the following code:


Aspose.Cells.License lic = new Aspose.Cells.License();


lic.SetLicense(@“D:\FileTemp\Aspose.cells.lic”);


Workbook wbd = new Workbook(@“D:\FileTemp\2.xls”);


FileStream fileStream = File.Create(@“D:\FileTemp\dest.csv”);


for (int i = 0; i < wbd.Worksheets.Count; i++)


{


wbd.Worksheets.ActiveSheetIndex = i;


wbd.Save(fileStream,SaveFormat.CSV); //Error


}


fileStream.Flush();


fileStream.Close();