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. 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.
Apparently according to the documentation, you can use AutoFitColumns(Double MinimumWidth, Double MaximumWidth) : Set the column width from the content of the range. Note: Cells containing formulas are ignored if no calculation is made. Wrapped and merged cells are also ignored.
Hide columns Select one or more columns, and then press Ctrl to select additional columns that aren't adjacent. Right-click the selected columns, and then select Hide.
Grouping Rows or ColumnsGroups and outlines allow you to quickly hide and unhide rows or columns in an Excel spreadsheet. The Groups feature creates row and column groupings in the Headings section of the worksheet. Each group can be expanded or collapsed with the click of a button.
I've found a solution for the columns.
I wanted to hide columns 10 to 16384 (last). 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With