简体   繁体   English

如何使用EPPlus在excel电子表格中隐藏大量列?

[英]How can I hide a large number of columns in an excel spreadsheet using EPPlus?

I am using EPPlus version 3.1.3 to create a spreadsheet and I want to hide all of the columns from column L to column XFD and all the rows from the bottom most row to the end. 我正在使用EPPlus 3.1.3版创建电子表格,我想隐藏从列L到列XFD的所有列以及从最底部行到结尾的所有行。 I'm trying to hide the columns by using: 我试图通过使用以下方式隐藏列:

for (int i = 12; i <= 16384; i++)
{
     worksheet.Column(i).Hidden = true; 
}

This takes forever though for this loop to run. 这需要永远运行此循环。 Does anyone know of an alternative way to hide a large amount of columns? 有没有人知道隐藏大量列的替代方法? I also have no idea how to hide the rows. 我也不知道如何隐藏行。

I'm wondering if there is another solution outside of EPPlus, but I really don't want to add another library to this. 我想知道EPPlus之外是否还有其他解决方案,但我真的不想为此添加另一个库。

I've found a solution for the columns. 我找到了一个列的解决方案。

I wanted to hide columns 10 to 16384 (last). 我想隐藏第10至16384列(最后一篇)。 The following Code did the trick and has a good performance. 以下代码完成了这项工作,并且性能良好。

//EPPlus 4.04 is used.

Dim col As ExcelColumn = osheet.Column(10)
col.ColumnMax = 16384
col.Hidden = True

Does either of these work? 这些都有效吗?

worksheet.columns("L:XFD").Hidden=True 

or 要么

worksheet.columns("12:16384").Hidden=True

(please forgive me if these are miles away as I don't know EPPlus too well) (如果这些距离很远,请原谅我,因为我不太了解EPPlus


EDIT 编辑

I think Sean Cheshire's comments answer your question? 我认为Sean Cheshire的评论回答了你的问题?

worksheet.cells("L:XFD").Hidden=True

The reference he provided seems to confirm this: EPPlus - Working with multiple columns by index rather than Alphabetical Representation 他提供的参考似乎证实了这一点: EPPlus - 通过索引而不是按字母表示法处理多个列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM