Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: Changing a Column Header's text [9383]

$
0
0
I am trying to change the text of cells in the first row of the spreadsheet, essentially the column header.

This example is just changing the first cell in row 1.

```
Dim l_sValue As String
l_sValue = "test"
wb.Worksheets(0).Cell(1, 1).DataType = XLCellValues.Text
wb.Worksheets(0).Cell(1, 1).Value = l_sValue
```

However, when I do this the spreadsheet needs to be repaired when I open it. If I change any cell other than a cell in row 1 I have no issues.

I need to modify the column headers so they have a better meaning and can't do this in the DataTable that I am importing from.
Comments: I have the exact same issue! - Created worksheet from datatable using ``` XLWorkbook wb = new XLWorkbook(); var temp_ws = wb.Worksheets.Add(datatable, "SheetName"); ``` - Changed a value in first row (a header cell value) ``` temp_ws.Cell(1, 1).Value= "Label"; ``` - When I tried to save the file it saves, but when trying to open it I get the following prompt ``` We found a problem with some content in "Test.xlsx" Do you want us to try to recover as much as we can? ``` - If i clicked yes the file opens but it shows ``` Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded. Repaired Records: Table from /xl/tables/table1.xml part (Table) ``` - If i changed value in any other cell (other then first row) it changes fine and error messages does not appear. - If I didnt change any value (just let the excel use the default labels of the datatable) It saves and opens fine, but as OP stated, I need to change label values at excel level not datatable level (it should not be a problem since other values can be changed fine, why only the first row have problems?) Any fix / workaround is appreciated

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>