[英]How to remove filter from table in excel created by spreadsheet-light import data from a DataTable function.
I'm using Spreadsheet-light for creating excel document. 我正在使用Spreadsheet-light创建Excel文档。 I need to use a method "import data from a DataTable".But the table has filter by default. 我需要使用“从DataTable导入数据”方法。但是默认情况下,该表具有过滤器。 i do not want this filter. 我不要这个过滤器。
I tried a inbuilt method of Spreadsheet-light 我尝试了Spreadsheet-light的内置方法
sl.RemoveFilter();
to remove the filter but it's not working.Can any one suggest how to remove this default filter. 删除过滤器,但无法正常工作。有人可以建议如何删除此默认过滤器。 Please look into my code. 请查看我的代码。
int iStartRowIndex = 11;
int iStartColumnIndex = 2;
sl.ImportDataTable(iStartRowIndex, iStartColumnIndex, dtMyTable,true);
int iEndRowIndex = iStartRowIndex + dtMyTable.Rows.Count + 1 - 1;
int iEndColumnIndex = iStartColumnIndex + dtMyTable.Columns.Count - 1;
SLTable table = sl.CreateTable(iStartRowIndex, iStartColumnIndex, iEndRowIndex, iEndColumnIndex);
table.SetTableStyle(SLTableStyleTypeValues.Medium17);
sl.RemoveFilter();
sl.InsertTable(table);
sl.SaveAs("FileName");
This might come as a shock to you, but the solution is weirdly simple.. 这可能会让您感到震惊,但是解决方法很简单。
Just replace the statement 只需替换语句
sl.RemoveFilter();
with this: 有了这个:
table.HasAutoFilter = false;
It took me some time to figure this out.. Some documentation is definitely needed for this!! 我花了一些时间才弄清楚。.绝对需要一些文档!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.