EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
289 stars 50 forks source link

Table With no rows #245

Open BorisVolkan opened 2 months ago

BorisVolkan commented 2 months ago

There is a problem with this code:

var activitiesTable = document.AddTable(1, numberOfColumns, WordTableStyle.TableGrid);
activitiesTable.Rows[0].Remove();
var headerRow = activitiesTable.AddRow();

The exception that I get i: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

Can you make the WordTable constructor accept 0 as rowCount, or handle AddRow method for this scenario.

Thank you

PrzemyslawKlys commented 2 months ago

The problem is that Table without rows and cells and at least paragraph in a cell creates broken document. So while technically it would be possible to do that, it would probably create other issues. Why can't you simply add header row content/table content normally?