I have been previewing your product and I seem to have run into a bit of a snag. What I have done is selected the range of my document and applied a style so I can set my default Font.Name and Font.Size. Then, I try to set the first cell's Font to italic ( sheet.Cells[0,0].Style.Font.IsItalic = true ), but the entire document seems to have it's font set to italics then. Shouldn't I be able to modify a single property of a style for a single cell? Thanks in advance.
Internally, is there a mapping to a Style in the Styles collection and that’s it? If the second option is what you are suggesting (using the Copy method), should it be the default behavior that when you reference a Cell’s Style property that it do an implicit copy of itself? Additionally, if I then wanted to do something like this:
I would just expect that for only that range the IsItalic property would be set to true while retaining the other properties of the previous Style that it had. Anyway, sorry for being wordy, I am just having a hard time figuring out why changing a Style of an individual cell would change the rest of the cells that had the same Style. Thanks for the response!
You may try the following sample code (suggested by Laurence), here the A1 cell will have additional italic attribute and all other cells in A1:D11 range will retain its previous attributes.
using Excel = Aspose.Cells;
//Define the font face and borders for a cell range Excel.Range rng = sheet.Cells.CreateRange("A1","D11"); Excel.Style style = book.Styles[book.Styles.Add()]; style.Font.Name = "Calibri"; style.Borders.SetStyle(Aspose.Cells.CellBorderType.Thin); style.Borders.DiagonalStyle = Aspose.Cells.CellBorderType.None; rng.Style = style;