wordpress hit counter
Welcome to OpenXML Developer Sign in | Join | Help

Cell format changes after 5 rows?

Last post 02-05-2010, 3:10 PM by ChuckW. 1 replies.
Sort Posts: Previous Next
  •  02-02-2010, 10:35 AM 8073

    Cell format changes after 5 rows?

    I am using an Excel Template file in VB.Net to create a spreadsheet populated from a dataset. The template file has one column that is formatted as Number. Looping through the dataset, I insert the current data into the cell formatting the value as and set the datatype of the cell to Number as shown below.

    cell.CellValue = New CellValue(String.Format("{0:f}", value))
    cell.DataType =
    New EnumValue(Of CellValues)(CellValues.Number)

    Beginning with the fifth row in the resulting spreadsheet, the format of the rest of the cells in that column are formatted as General instead of Number.

    Any ideas on why this would be happening?

  •  02-05-2010, 3:10 PM 8114 in reply to 8073

    Re: Cell format changes after 5 rows?

    I figured it out. The Template only contained five rows in the sheet1.xml. When I added the 6th row, since I wasn't specifying an existing style and format, it defaulted to General. I now add a style to the cell and it works as expected.
View as RSS news feed in XML