简体   繁体   中英

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. 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.

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

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)


EDIT

I think Sean Cheshire's comments answer your question?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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