This project has moved. For the latest updates, please go here.

excel filter

Sep 5, 2012 at 11:26 AM
                if (dt.Rows.Count > 0)
                {
                    var wb = new XLWorkbook();
                    wb.Worksheets.Add(dt);                    
                    wb.SaveAs(outputPath + "\\ACS.xlsx");
                }

hi to all,

i am creating an excel file with the above code.

my problem(?) is that when i am opening the excel it has the filter enable. how can i overide?

 

thanks in advance

Coordinator
Sep 5, 2012 at 1:42 PM

There are so many things you can do...

  • Remove the Excel table while leaving the data.
  • Turn off the filters on the table (table.ShowAutoFilter)
  • Add the worksheet then insert the data table as data (cell.InsertData)
  • Add the worksheet then insert the table without creating an Excel formatted table (cell.InsertTable(table, false))
  • There are probably other ways...
Sep 5, 2012 at 2:49 PM

in my example, can yoy help me?

 

Coordinator
Sep 5, 2012 at 3:05 PM
Edited Sep 5, 2012 at 3:05 PM

I gave you 4 solutions. Did you try to make any of them work?

Sep 6, 2012 at 6:03 AM

1) i cannot undestand where i add the excel table so i will remove it later. i only add worksheets

2) i cannot found the table.ShowAutoFilter command because i do not have table anywhere

3-4) when i am going to add Worksheets, it waits a datatable.

That's why i asked again

thanks for replay

Coordinator
Sep 6, 2012 at 7:37 PM

1) wb.Worksheets.Add(dt).Tables.Remove(0);

2) var table = wb.Worksheets.Add(dt).Tables.First();

3-4) var ws = wb.Worksheets.Add("Sheet1");

Sep 8, 2012 at 1:14 AM

thank you a lot