Multi-Sheet Workbook Saved As Text

I'm using the following code snippet to save multiple sheets to a memory stream, then save to a file once complete. However, for some reason the workbook.Worksheets.ActiveSheetIndex = X is being ignored. The end result is the first sheet is written to disk multiple times (once for each sheet) and the other sheets are being ignored.

I have not made any changes to the code snippet from the help guide. Any ideas?

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

I have tested the given code in the article and found, it is working fine. I have used the latest version: Aspose.Cells for .NET 7.3.5 for testing its code.

Please make sure that you are using the correct Aspose.Cells dll.

1 - For any Normal NET Framework (>2.0), please use the dll inside the net2.0 folder
2 - For any ClientProfile Net Framework (>3.5), please use the dll inside the net3.5_ClientProfile folder

I have also attached the source output files generated by the following code and screenshot for your reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


//Load your source workbook

Workbook workbook = new Workbook(filePath);


//0-byte array

byte[] workbookData = new byte[0];


//Text save options. You can use any type of separator

TxtSaveOptions opts = new TxtSaveOptions();

opts.Separator = ‘\t’;


//Copy each worksheet data in text format inside workbook data array

for (int idx = 0; idx < workbook.Worksheets.Count; idx++)

{

//Save the active worksheet into text format

MemoryStream ms = new MemoryStream();

workbook.Worksheets.ActiveSheetIndex = idx;

workbook.Save(ms, opts);


//Save the worksheet data into sheet data array

ms.Position = 0;

byte[] sheetData = ms.ToArray();


//Combine this worksheet data into workbook data array

byte[] combinedArray = new byte[workbookData.Length + sheetData.Length];

Array.Copy(workbookData, 0, combinedArray, 0, workbookData.Length);

Array.Copy(sheetData, 0, combinedArray, workbookData.Length, sheetData.Length);


workbookData = combinedArray;

}


//Save entire workbook data into file

File.WriteAllBytes(filePath + “.out.txt”, workbookData);


Screenshot:
CashCache:

I'm using the following code snippet to save multiple sheets to a memory stream, then save to a file once complete. However, for some reason the workbook.Worksheets.ActiveSheetIndex = X is being ignored. The end result is the first sheet is written to disk multiple times (once for each sheet) and the other sheets are being ignored.

I have not made any changes to the code snippet from the help guide. Any ideas?

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We have looked into your issue further and found that workbook.Worksheets.ActiveSheetIndex is being ignored because you are using Evaluation Version of Aspose.Cells.

Once, you will set the License, you will not get this behavior. In order to set license, you will have to purchase license which you can get from Aspose.Purchase department.

I appreciate the reply, but how can I evaluate the performance of your product if the Evaluation License cripples the API to the point it's unusable/testable?

So far the product seems pretty solid. However, I've never seen a license that limits functionality to the point where you can't tell if the evaluation license is limiting the functionality or if it's a bug in the software.

I need to test the product completely before purchasing. What do you recommend?

CashCache:

I appreciate the reply, but how can I evaluate the performance of your product if the Evaluation License cripples the API to the point it's unusable/testable?

So far the product seems pretty solid. However, I've never seen a license that limits functionality to the point where you can't tell if the evaluation license is limiting the functionality or if it's a bug in the software.

I need to test the product completely before purchasing. What do you recommend?

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

While using Evaluation Version, Aspose.Cells will not let you change ActiveSheetIndex because it needs to set Evaluation Worksheet as Active Sheet.

For testing purpose, you should get Temporary License from Aspose.Purchase department.

It will give you 30-Days Temporary License for your testing needs. Aspose.Cells will run in full capacity when you will set this license.