删除从ClosedXML中的InsertTable方法创建的表的所有格式 [英] Remove all formatting of the table created from InsertTable method in ClosedXML
问题描述
我正在使用ClosedXML生成报告.提供给Excel的数据来自存储在DataTable对象中的数据库.该表在Excel工作表中显示良好-但是,它在创建的表上应用了默认主题. 下面是我的示例代码:
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)
这是结果:
我想删除所创建表的粗体字体样式.但是,当我这样做时
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.
推荐答案
我今天想通了.这是一个非常明显的错误. 我不应该使用AsTable(),因为我要格式化的单元格已经在表中了.这是由于某些原因导致VS2010的智能感知能力差的结果,因此Table.Theme()不在上下文菜单中显示.我发现自己的问题已解决.应该是:
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
这篇关于删除从ClosedXML中的InsertTable方法创建的表的所有格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!