I use Aspose.Cells to create a Excel file. I also save it as a PDF file.
That file has some fields that are aligned to the right. They appear correctly in Excel. When the very same file is exported to a PDF file, very often, the content is cut at very weird place (looks like it cut on the column width).
You will find attach my Excel file, the xml to generate it and the outputed PDF. Look at page 9 of the PDF for an example (should read "Asset Under Management:" and "Bank Proprietary:")
I have tested your file and found that the error is caused by the xml which is generated by Aspose.Cells. If you look in the xml file you can see that the "Asset U" is in one cell and "nder Management:" is in another. I am moving this to the Aspose.Cells forum so that the Aspose.Cells team can take a look at it.
In this fix,we use Cell.GetStyle and SetStyle method replace the property of Cell.Style. The two methods will save more memory usage than cell.Style property.
If you want to set style of the cell, please change your codes as :
Also when I modify the style for a cell, the formatting remains for the following cell. It wasn't like this before. It will be a pain if we need to change this everywhere.
Please try the fix (4.4.1.8) downloading it from the the thread: <A href="</A>.</P>
<P>In this fix, we add a method Style.Update for your need. <FONT face=宋体>For a named style, if you want to change the Style, you may call Style.Update method. </FONT><FONT face=宋体>Otherwise the style of cell will not be changed. Style.Update method behaves like an "OK" button i.e., when you have done your modified with some Style, you may call it for final implementation.
Please try the attached version (4.4.1.9), it will resolve your issues. The attachment also contains styledemo with template excel file to better understand how you can use SetStyle, GetStyle methods of Cell class and where you can use Update method of the Style class.
Do we still have to use .GetStyle and .SetStyle or can we use the .Style property directly like we use to do in the past?
In this fix, we retain the Style property of the Cell class for the users. You may utilize Cell.Style property but using separatedly Cell.GetStyle and Cell.SetStyle certainly would be better choices for performance optimization in the long run.
Do you call the .Style.Update method after the .SetStyle method?
Please check the styledemo for reference, Cell.SetStyle() is used to apply a style to a cell whereas Style.Update method is used to modify an existing style (if you have already applied some style to a range of cells and you modify the style using Style.Update method, the style formattings of those cells would be upldated too.)
Do you have an example handy? For example, say I want to give a cell a basic type and set borders around it. What would the code look like?
If remove the line style.Update() in ChangePreDefinedNamedStyle demo, you will see "Percent" Style in Format|Style, the number format of Percent Style has been changed as "m/d/yyyy", but the number format of Range A1:C8 still is "0%" not "m/d/yyyy" in Ms Excel(The version is Excel 2003 sp3 in my machine).
In Ms Excel, if you change the "Percent" style in the book1.xls in the demoes, the style of range A1:C8 should be changed also.The method style.Update is used to change style of range A1:C8.
Could you try to remove style.Update() in that demo to check the number format of Range A1:C8?
Cells cells = workbook.Worksheets[0].Cells; cells["A1"].SetStyle(style); Range range = cells.CreateRange("B1", "D1"); StyleFlag flag = new StyleFlag(); flag.All = true; range.ApplyStyle(style, flag);
//if the named style has been set to cells or range, //you want to change it and change the style of the cells/range, please call style.Update(). style.Font.Color = System.Drawing.Color.Black; style.Update(); workbook.Save(@"F:\FileTemp\book3.xls");
If you do not call style.Font.Color = System.Drawing.Color.Black after you set the style to cell, you don't need to call style.Update().
If I understand correctly (and I may be wrong), ApplyStyle is used when working with a Range object.
Since I always format on a cell basis, I set a style object and then affect it to a cell using the SetStyle method. In this scenario, do I ever need to call the Update method.
I understand that this feature is quite new but it would be a good time to update your online documentation and have a clear example of when to use ApplyStyle, SetStyle, and Update methods.
1). Yes, ApplyStyle method is used to set a style to a range or worksheet cells.
2). Well, if you do't want to update / modify an existing style object (which you have already applied to some cell(s)), you do not need to utilize Style.Update() method.
3). We will soon update our documenatation with sample codes related newer APIs.