We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Export text in all worksheets

I use Aspose.Cells for Java 17.9 to export text from an Excel file.

Workbook book = new Workbook(xlsFilePath);
TxtSaveOptions opts = new TxtSaveOptions();
book.save(txtFilePath, opts);

The result file only has text in the 1st worksheet. How to export all worksheets?


Thanks for using Aspose APIs.

Please use the Workbook.Worksheets.ActiveSheetIndex for your needs. Please see the following sample code, its sample Excel file and its output Text files for your help.

Download Link:
Sample Excel and Output Text Files.zip (7.6 KB)


Workbook book = new Workbook(dirPath + "sample.xlsx");
TxtSaveOptions opts = new TxtSaveOptions();

for(int i=0; i<book.getWorksheets().getCount(); i++)

    Worksheet sh = book.getWorksheets().get(i);
    book.save(dirPath + "out-" + sh.getName() + ".txt");


Workbook book = new Workbook("sample.xlsx");
TxtSaveOptions opts = new TxtSaveOptions();
opts.Separator = '\t';

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

    Worksheet sh = book.Worksheets[i];
    book.Save("out-" + sh.Name + ".txt");