How to save each sheet as txt?

Hi, Support:

Is there any method to save each sheet as txt? In MS Excel ,it can save xls as txt,whereas I don’t find the api to save them as txt.

Thanks for your help.

@ducaisoft,

There is no method to directly save each sheet to txt.
You can hide all the worksheets except the worksheet that you want to save to txt, then save workbook to txt.

Workbook wb = new Workbook("Test.xlsx");
for (int i = 0; i < wb.Worksheets.Count; i++)
{
    wb.Worksheets[i].IsVisible = true;
    for (int j = 0; j < wb.Worksheets.Count; j++)
    {
        // save worksheet i to txt
        //hide all the worksheets except worksheet i
        if (j != i)
        {
            wb.Worksheets[j].IsVisible = false;
        }
    }
    TxtSaveOptions options = new TxtSaveOptions();
    options.FormatStrategy = CellValueFormatStrategy.None;
    options.SeparatorString = "\t";
    wb.Save(wb.Worksheets[i].Name + ".txt" , options);
}