ColumnMax exception when AutoFitColumns call followed by setting VerticalAlignment #27
Description
Here is a small test that will throw a "ColumnMax can not span..." exception (VS C++ project). It seems that the VerticalAlignment statement causes the exception if it is set AFTER the AutoFitColumns call.
This worked fine in version 4.0.4.0, I am now having to update to 4.1.1.0 because of the recent horrible VBA issue.
The exception does not occur if the alignment is set BEFORE the autofit call, but the effect will be that ALL columns to the right of column 3 will be hidden, not just 4 and 5. Is this the expected behavior? In 4.0.4.0 the alignment being set AFTER the autofit call ONLY hides columns 4 and 5.
============================================================
FileInfo ^file = gcnew FileInfo("C:\Temp\Test.xlsx");
ExcelPackage ^pck = gcnew ExcelPackage(file);
ExcelWorksheet ^ws = pck->Workbook->Worksheets->Add("Worksheet");
if (ws != nullptr) {
ws->Cells["A1"]->Value = "Cell value 1";
ws->Cells["B1"]->Value = "Cell value 2";
ws->Cells["C1"]->Value = "Cell value 3";
ws->Cells["D1"]->Value = "Cell value 4";
ws->Cells["E1"]->Value = "Cell value 5";
}
//ws->Cells->Style->VerticalAlignment = ExcelVerticalAlignment::Top; // Columns 4 and greater hidden
ws->Cells->AutoFitColumns(0);
ws->Cells->Style->VerticalAlignment = ExcelVerticalAlignment::Top; // 4.1.1.0 - exception, 4.0.4.0 - columns 4 and 5 hidden
ws->Column(4)->Hidden = true;
ws->Column(5)->Hidden = true; // span exception
pck->Save();