Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

ColumnMax exception when AutoFitColumns call followed by setting VerticalAlignment #27

Closed
davidgeewhiz opened this issue Oct 9, 2017 · 1 comment

Comments

@davidgeewhiz
Copy link

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();

JanKallman pushed a commit that referenced this issue Oct 11, 2017
@JanKallman
Copy link
Owner

Fixed in 4.5.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants