Exception thrown on second iteration of loop.
No problem when the first Heading call is omitted.
<package id="EPPlus" version="4.0.1.1" targetFramework="net45" />
System.Exception was unhandled
_HResult=-2146233088
_message=ColumnMax can not span over existing column 11.
HResult=-2146233088
IsTransient=false
Message=ColumnMax can not span over existing column 11.
Source=EPPlus
StackTrace:
at OfficeOpenXml.ExcelColumn.set_ColumnMax(Int32 value)
at OfficeOpenXml.ExcelWorksheet.CopyColumn(ExcelColumn c, Int32 col, Int32 maxCol)
at OfficeOpenXml.ExcelWorksheet.Column(Int32 col)
at OfficeOpenXml.ExcelRangeBase.get_Style()
at RepGener.Program.Heading(ExcelWorksheet& sheet, String text, Int32 fromRow, Int32 fromCol, Int32 toRow, Int32 toCol) in c:\WRAVS\CW61\RR\RepGener\RepGener\Program.cs:line 154
at RepGener.Program.Bug025() in c:\...\Program.cs:line 145
at RepGener.Program.Main(String[] args) in c:\...\Program.cs:line 64
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
/////////////
private static void Bug025()
{
var fi = new FileInfo("somefilename.xlsx");
var package = new ExcelPackage(fi);
var ws = package.Workbook.Worksheets.Add("Fred");
Heading(ref ws, String.Format("{0} [{1}]", "Fred", 2345), 2, 11, 2, 15);
for (var i = 0; i < 8; i++)
{
Heading(ref ws, Convert.ToString((DayOfWeek)(i + 1)), 5, 4 + i * 4, 5, 3 + 4 + i * 4);
}
package.Save();
}
private static void Heading(ref ExcelWorksheet sheet, string text, int fromRow, int fromCol, int toRow, int toCol)
{
sheet.Cells[fromRow, fromCol, toRow, toCol].Merge = true;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.Font.Size = 10;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.Font.Bold = true;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
sheet.Cells[fromRow, fromCol, toRow, toCol].Value = text;
}
No problem when the first Heading call is omitted.
<package id="EPPlus" version="4.0.1.1" targetFramework="net45" />
System.Exception was unhandled
_HResult=-2146233088
_message=ColumnMax can not span over existing column 11.
HResult=-2146233088
IsTransient=false
Message=ColumnMax can not span over existing column 11.
Source=EPPlus
StackTrace:
at OfficeOpenXml.ExcelColumn.set_ColumnMax(Int32 value)
at OfficeOpenXml.ExcelWorksheet.CopyColumn(ExcelColumn c, Int32 col, Int32 maxCol)
at OfficeOpenXml.ExcelWorksheet.Column(Int32 col)
at OfficeOpenXml.ExcelRangeBase.get_Style()
at RepGener.Program.Heading(ExcelWorksheet& sheet, String text, Int32 fromRow, Int32 fromCol, Int32 toRow, Int32 toCol) in c:\WRAVS\CW61\RR\RepGener\RepGener\Program.cs:line 154
at RepGener.Program.Bug025() in c:\...\Program.cs:line 145
at RepGener.Program.Main(String[] args) in c:\...\Program.cs:line 64
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
/////////////
private static void Bug025()
{
var fi = new FileInfo("somefilename.xlsx");
var package = new ExcelPackage(fi);
var ws = package.Workbook.Worksheets.Add("Fred");
Heading(ref ws, String.Format("{0} [{1}]", "Fred", 2345), 2, 11, 2, 15);
for (var i = 0; i < 8; i++)
{
Heading(ref ws, Convert.ToString((DayOfWeek)(i + 1)), 5, 4 + i * 4, 5, 3 + 4 + i * 4);
}
package.Save();
}
private static void Heading(ref ExcelWorksheet sheet, string text, int fromRow, int fromCol, int toRow, int toCol)
{
sheet.Cells[fromRow, fromCol, toRow, toCol].Merge = true;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.Font.Size = 10;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.Font.Bold = true;
sheet.Cells[fromRow, fromCol, toRow, toCol].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
sheet.Cells[fromRow, fromCol, toRow, toCol].Value = text;
}