Remove all formatting of the table created from InsertTable method in ClosedXML

一笑奈何 提交于 2019-12-23 16:17:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!