Alignment problem when i save as text file

Hi Team

I am using Aspose.Cells to create a text file.Using SavetoCSV or SavetoTabDelimeted im saving the file. But output file is not in correct alignment.

Please help me to solve this problem.

Hi,

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

Please download and use the latest version:
Aspose.Cells
for .NET v7.3.1.1



Please note, CSV and Tab Delimited Format are very naive and text formats, they do not support complex objects like styles and alignments.

Therefore you cannot align anything in CSV or Text formats. These formats are just used to store data only.

If you want to use Style objects like Alignment (Left, Right, Middle, Center), Colors (Fore and Back Colors), Borders etc, then please use the advanced binary and xml formats like Xls and Xlsx formats.

To save your workbook into more advanced formats, please refer to this article.


Below is a sample code for your reference which creates a workbook, add some text inside cell A1 and then saves the workbook in xlsx format.

C#

//Create a workbook from scratch

Workbook workbook = new Workbook();


//Write something in cell A1 of first worksheet

Worksheet worksheet = workbook.Worksheets[0];


Cell a1 = worksheet.Cells[“A1”];

a1.PutValue(“Hello Aspose!”);


//Autofit columns

worksheet.AutoFitColumns();


//Save your workbook in xlsx format

workbook.Save(“output.xlsx”, SaveFormat.Xlsx);


Hi,


It looks like you are using some older version of the product (Aspose.Cells for .NET) as SaveToCSV or SaveToTabDelimeted methods are obsolete, you may use SaveOptions instead.
See the document:
http://www.aspose.com/docs/display/cellsnet/Saving+Files

See a sample code below:

Sample code:
Workbook workbook = new Workbook();
//Your code goes here.
//…

//Instantiate Text File’s Save Options
TxtSaveOptions options = new TxtSaveOptions(SaveFormat.TabDelimited);
//Set your desired options if you want.
//…

workbook.Save(“e:\test2\Test.txt”, options);


Moreover, please try our latest fix/version: Aspose.Cells for .NET v7.3.1.1 Aspose.Cells should work the same way as MS Excel does.

If you still find any difference with MS Excel regarding your text formats, kindly give us your sample code and template file(s) here, we will check your issue soon.

Thank you.