S
Stand1987
I'm trying to turn off all the filter on a worksheet in order to get all the
values in a specified column. I'm able to get all the values from a column in
the worksheet, but I'm still not able to turn-off all the filters in the
worksheet. Here my sample code below:
// Create an instance of the Excel Application
Microsoft.Office.Interop.Excel.Application xlApp = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel._Workbook xlWorkbook;
Microsoft.Office.Interop.Excel._Worksheet xlWorksheet;
try
{
// Opens the Excel Application with the specified file
xlWorkbook = xlApp.Workbooks.Open(f, 0, false, 5, "", "",
false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false,
0, true, false, false);
// Creates and initize a worksheet
xlWorksheet = new
Microsoft.Office.Interop.Excel.WorksheetClass();
// Get the worksheet at that location in the workbook
xlWorksheet =
(Microsoft.Office.Interop.Excel.Worksheet)xlWorkbook.Worksheets.get_Item(n);
// Check weather Worksheet has a filter
if (xlWorksheet.FilterMode)
{
// Turns off the Filter on the Worksheet.
xlWorksheet.EnableAutoFilter = false;
xlWorksheet.AutoFilterMode = false;
}
// Unfreeze the pane
xlWorksheet.Application.ActiveWindow.FreezePanes = false;
Any help would be great,
thanks,
values in a specified column. I'm able to get all the values from a column in
the worksheet, but I'm still not able to turn-off all the filters in the
worksheet. Here my sample code below:
// Create an instance of the Excel Application
Microsoft.Office.Interop.Excel.Application xlApp = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel._Workbook xlWorkbook;
Microsoft.Office.Interop.Excel._Worksheet xlWorksheet;
try
{
// Opens the Excel Application with the specified file
xlWorkbook = xlApp.Workbooks.Open(f, 0, false, 5, "", "",
false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false,
0, true, false, false);
// Creates and initize a worksheet
xlWorksheet = new
Microsoft.Office.Interop.Excel.WorksheetClass();
// Get the worksheet at that location in the workbook
xlWorksheet =
(Microsoft.Office.Interop.Excel.Worksheet)xlWorkbook.Worksheets.get_Item(n);
// Check weather Worksheet has a filter
if (xlWorksheet.FilterMode)
{
// Turns off the Filter on the Worksheet.
xlWorksheet.EnableAutoFilter = false;
xlWorksheet.AutoFilterMode = false;
}
// Unfreeze the pane
xlWorksheet.Application.ActiveWindow.FreezePanes = false;
Any help would be great,
thanks,