Can all hidden columns in an Excel worksheet be revealed?
This is the code I use to reveal every hidden row. I don't want to repeatedly cycle through and verify how many columns are being used in the range.
foreach (string filePath in _allFiles)
{
try
{
_wb = _app.Workbooks.Open(filePath, ReadOnly: false);
foreach (Excel.Worksheet ws in _wb.Worksheets)
{
try
{
string abc = ws.Name;
ws.ShowAllData(); /* needs try catch 'cause if no filters are applied, it will throw an exception */
}
catch (Exception ex)
{ }
}
}
catch (Exception ex2)
{ }
finally
{
_wb.Save();
_wb.Close();
//_app.Quit();
//Marshal.ReleaseComObject(_app);
}
}
_app.Quit();
Marshal.ReleaseComObject(_app);