I would like each cell in the header to contain an autofilter. Below is the code I'm trying to use however the autofilter
only gets set on the last cell specified.
For example, if I comment out the autofilter
command for K1
, the spreadsheet will be created with C1
being the only cell with an autofilter.
//Headers ws.Cells["A1"].Value = "ChannelCode"; ws.Cells["A1"].AutoFilter = true; ws.Cells["B1"].Value = "DrmTerrDesc"; ws.Cells["B1"].AutoFilter = true; ws.Cells["C1"].Value = "IndDistrnId"; ws.Cells["C1"].AutoFilter = true; ws.Cells["D1"].Value = "StateCode"; ws.Cells["D1"].AutoFilter = true; ws.Cells["E1"].Value = "ZipCode"; ws.Cells["E1"].AutoFilter = true; ws.Cells["F1"].Value = "EndDate"; ws.Cells["F1"].AutoFilter = true; ws.Cells["G1"].Value = "EffectiveDate"; ws.Cells["G1"].AutoFilter = true; ws.Cells["H1"].Value = "LastUpdateId"; ws.Cells["H1"].AutoFilter = true; ws.Cells["I1"].Value = "ErrorCodes"; ws.Cells["I1"].AutoFilter = true; ws.Cells["J1"].Value = "Status"; ws.Cells["J1"].AutoFilter = true; ws.Cells["K1"].Value = "Id"; ws.Cells["K1"].AutoFilter = true;
EPPlus .AutoFilter
is a little buggy... I suggest doing it using a range like this:
ws.Cells["A1:K1"].AutoFilter = true;
For all sheet data range
worksheet.Cells[worksheet.Dimension.Address].AutoFilter=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