问题
I'm using ClosedXML to generate a report. The data supplied to Excel is from a database which is stored to a DataTable object. The table is displayed fine in the Excel sheet - however, it has a default theme applied on the created table. Below is my sample code:
Dim workbook As XLWorkbook = New XLWorkbook()
Dim _tempSummary= workbook.AddWorksheet("Summary").Cell(1, 1).InsertTable(tblSummary)
This is the result:
I wanted to remove the bold font styling of the created table. However, when I did this
_tempSummary.AsTable().Ranges("B1:G1,I1:O1,Q1:R1").Style.Font.SetBold(False)
It doesn't seem to work. Please tell me what I'm doing wrong. Thanks in advance.
回答1:
I figured it out today. It was a very obvious mistake. I should have not used AsTable() since the cells I wanted to format are already in a table. This is the result of bad intellisense of VS2010, for some reason Table.Theme() doesn't show up on the context menu. I found the fixed of me own problem. It should have been:
_tempSummary.Theme() = XLTableTheme.None
来源:https://stackoverflow.com/questions/34338164/remove-all-formatting-of-the-table-created-from-inserttable-method-in-closedxml