Style and format only works for xls

Hi There,


I have applied the same style to the same row. but when I export the workbook to pdf and csv report. The text in the columns was cut but not in xls report. How can I have the same style for pdf or csv report. thanks,

Tony

Hi,

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

CSV is a very simple and text based format, it does not support complex objects like styles.

PDF and XLS is a binary format and it does support complex objects e.g styles etc.

Please download and try the latest version:

Aspose.Cells for .NET 7.3.1

and let us know your feedback.

If your problem still occurs with the latest version, please provide us your source files and the code to replicate this issue. We will look into it and help you asap.

Hi,


The following is my code
int y = workbook.Styles.Add();

//Accessing the newly added Style to the Excel object
Style styleContent = workbook.Styles[y];

//Setting the vertical alignment of the text in the “A1” cell
styleContent.VerticalAlignment = TextAlignmentType.Left;

//Setting the horizontal alignment of the text in the “A1” cell
styleContent.HorizontalAlignment = TextAlignmentType.Left;

//Setting the font color of the text in the cell
styleContent.Font.Color = Color.Black;

//Shrinking the text to fit in the cell
styleContent.ShrinkToFit = false;

styleContent.IsTextWrapped = true;

//Creating StyleFlag
StyleFlag styleFlag = new StyleFlag();
styleFlag.HorizontalAlignment = true;
styleFlag.VerticalAlignment = true;
styleFlag.ShrinkToFit = false;
styleFlag.WrapText = true;
styleFlag.FontBold = false;
styleFlag.Borders = true;

styleFlag.FontColor = true;

foreach (Row item in workbook.Worksheets[0].Cells.Rows)
{
item.ApplyStyle(styleContent, styleFlag);
}


I have attached two reports you will find the wraptext is only working for xls.
Thanks,
Tony

Hi,

Thanks for your sample code.

Please provide us your complete runnable test code to replicate this issue using the latest version. It will help us look into your issue better.

However, when I convert your output xls file into pdf file, I am able to notice the issue as you have mentioned.

We have logged this issue in our database. We will look into it and fix the issue and once the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-40999.

I have attached the output pdf for your reference.

C#



string filePath = @“F:\Shak-Data-RW\Downloads\Report+(3).xls”;


Workbook workbook = new Workbook(filePath);


workbook.Save(filePath + “.out.pdf”, SaveFormat.Pdf);

Hi,

Thanks for the sample files.

I can notice the issue as you have mentioned by simply opening your template ""Report+(3).xls" file and saving to PDF file, here is the simplest sample code to reproduce the issue:

Sample code:

Workbook wb = new Workbook("Report+(3).xls");
wb.Save("Report+(3).pdf", SaveFormat.Pdf);

As we have logged the ticket with an id: CELLSNET-40999. We will further investigate it and look into it to figure it out soon.

Thank you.

Hi,

Aspose.Cells does not auto fit the row height if the cell’s style.IsTextWrapped is true for performance issue.

Please manual calling the feature of auto fit.

See following code:

C#


Workbook workbook = new Workbook(@“D:\FileTemp\Report+(3).xls”);

AutoFitterOptions options = new AutoFitterOptions();

options.OnlyAuto = true;

workbook.Worksheets[0].AutoFitRows(options);

workbook.Save(@“D:\FileTemp\dest.pdf”);