I'm using the following code. Only fields not filled in with data from the first line have the style from the second line.
'Adds data to the worksheet Report.Cells.ImportDataTable(dt, False, "A5")
'Sets style for column 4 Report.Cells.Columns(4).Style.Number = 14
I cannot set the style with the xls template for other reasons so I just wanted to make column 4 display with the date cell format. Rows 0-4 , column 4 are empty but end up with the correct style (number 14). However, the cells (rows 5-x) in the column filled in by the ImportDataTable do not have the style. Any ideas why this is happening?
I have a similar problem. If I set the style of a column, any data written to that column gets reformatted to General. The column itself does still have the formatting, (as tested by entering data into the next empty row), but the data written by Cell.setValue seems to override the column's current style.
If you want to apply the column' style to each cell in this column, you should set the column's style first. And we will afford Column.ApplyStyle() method to apply style to each cell in this column.
Please try this fix for Java.You can set data first and use Column.applyStyle() method to set the column style and the style of the cells in the column.
Is there a way to set the Column Style first and then have cell.setValue not overwrite it? There are times when it would be easier to apply the styles first, such as when using dynamic columns.
Also, does applyStyle also set the set the style, or should I also call column.setStyle()?