Styling problems after upgrading from v 4.8 to 7.3

We recently upgraded from v4.8 to v7.3 for Aspose.Cells. Since then we are facing a lot of issues in our exports.

The only change that we did is that now we are using the methods Cell.GetStyle() and Cell.SetStyle(), instead of previously used Cell.Style property.

I have attached a screenshot of the code changes and the Excel sheets before and after the upgrade.

Kindly look into it and provide us with a solution.

Hi,


We introduced many new enhancements and changes in the later version of the product. Cell.GetStyle / Cell.SetStyle is one of them. The Cell.SetStyle/GetStyle is more refined approach, rather better for performance grounds in the long run.
Well, I think it might be an issue with your code that you have updated while upgrading to v7.3.x from your older version. Please double check your code and correct it in accordance with latest APIs set. If you still could not evaluate and you find any issue while applying formatting to cells/range/row/column etc., kindly separate the issue and create a console application with latest version, zip it and post it here with template file, we will check your issue and help you out to fix it.

Moreover we recommend you to kindly browse our online Documentation, especially the topics in the section/sub-section:



Thank you.

Hi Amjad,


As i mentioned the only changes that we have made in the code are that - we have used the methods Aspose.Cells.Cell’s GetStyle() and SetStyle() property instead of Style property and nothing else and that too only because the new library doesnt have the property Style but has the seetter and getter methods, i certainly get a feeling that the issue is with the library itself and not in our code.

Still i am working on isolating the issue as required by you and i will upload the console application soon.
Just wanted to confirm that
should i simply upload the zip with the license file,
or should i password protect it,
or should i remove the license files before uploading? Please confirm

Hi,


We are waiting your application to evaluate your issue properly. We really appreciate your work (as you are creating a console application to reproduce the issue) in this regard.

Also, please exclude your license file in your project, no need to attach your license file with the application.

Thank you.

Hi

i am attaching the zip of VisualStudio solution. There are two projects one with old version and one with new.
The output excel files are in the respective bin folders.

Kindly check. At this point of time i could reproduce only one issue and that is - a text’s cell size doesnt expand according to the Text size.

Hi,


Thanks for the project.

I have tested your project and I found I think Aspose.Cells new version works the same way as MS Excel does regarding AutoFit Rows operation. For confirmation I have done the Auto-Fit operation in MS Excel manually on your older version’s exported file which will be same as per your new version’s exported file after the operation. In short, it is not an issue with the product.

See the screen shot below.

I think you may try to set the rows heights accordingly (for the first two rows) instead of setting auto-fit rows operation for the first two rows.

Thank you.
I got your point for this one.
But thers another issue that i unable to comprehend.

The new version doesnt color the the 3rd column for some of the rows. However all rows are colored in the older version.

Kindly refer the same zip.

Hi,


I found the culprit line of code in your project (for new version), please change your lines of code segment i.e…,
//…
if (!surveyCompare)
cell.GetStyle().ForegroundColor = (Color)colorConverter.ConvertFromString("#dce9f0");

to:

//…
if (!surveyCompare)
{
Style stl = cell.GetStyle();
stl.ForegroundColor = (Color)colorConverter.ConvertFromString("#dce9f0");
stl.Pattern = BackgroundType.Solid;
cell.SetStyle(stl);

}

I have tested replacing the lines and it works as expected, all the cells in the C column are now set with proper formattings.

FYI, in the new version you cannot directly update the formatting by using the single line i.e.:
cell.GetStyle().ForegroundColor = (Color)colorConverter.ConvertFromString("#dce9f0");
so, you have to first get the style of the cell, then update the formatting and then apply the style to the cell (all in three steps) accordingly. Although it adds some extra lines to the code but it would be fruitful to do it as we have eliminated the older Cell.Style property in the new versions and replaced it with Cell.GetStyle()/SetStyle approach which is more efficient and better regarding performance grounds.

Hope, you understand now.

Thank you.

Hi Amjad,


I figured that out.
This is what i was saying. That is code being the same, just using GetStyle() and SetStyle() instead of Style property affects the styling.

The answer you gave could have been the first answer to this post, and would have saved a lot of my time.

Just to add i found out that GetStyle() and SetStyel() works differently that Style property (for a particular version). But because the Style property is not available in newer version, you have to resort to GetStyle0 and SetStyle().

So in short, the newer version Aspose does break an older code by not using Style property and the substitute GetStyle() doesnt work the same as property,
thus breaking your older code.

Also, i am having some issues in Pdf as well, the only change is that instead of Aspose.Pdf.Pdf class we are now using Aspose.Pdf.Generator.Pdf class.
This is the only change that we have done in our code. Now what about this?

Hi,


Well, I mentioned about Cell.GetStyle() and Cells.SetStyle() methods which are replaced by Cell.Style property in my first post. Also in your first post you did not post your project so, how could I figure it out for the issue regarding Cells.Style property. Also, in one of your later posts, you gave me the project but your main focus / issue is for Aut-Fit operation, so I sorted it out firstly. In one of your last post, you told me about the issue for some cells in the columns are not formatted properly so I double checked your code and pointed out the error. Anyways, we are happy that your issues are resolved now.

For:
Also, i am having some issues in Pdf as well, the only change is that instead of Aspose.Pdf.Pdf class we are now using Aspose.Pdf.Generator.Pdfclass.
This is the only change that we have done in our code. Now what about this?

Please post your query into Aspose.Pdf forums, one the developer (technical support) will help you soon there.

By the way, if you need to directly save the Excel file/workbook to PDF, you may use only Aspose.Cells component and no need to use Aspose.Pdf component for the intermediate conversion for PDF rendering any more now. See the topic for your reference:
http://www.aspose.com/docs/display/cellsnet/Converting+to+PDF+Files

Thank you.

Thanx for the help.

I will get back to you in case i need some more help.

Hi,

Thanks for your posting and using Aspose.Cells.

We welcome your any further queries. Please feel free to post, if you find any other issue, we will be glad to help you more.

Also, you can download and try the Offline Java Demos of Aspose.Cells for Java.

It contains simple runnable console examples which will help you to get familiar with Aspose.Cells for Java API (s) quickly and you will be able to upgrade your existing code.