tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.49k stars 418 forks source link

Adding named range causes file corruption #455

Open logicaldecisions opened 4 years ago

logicaldecisions commented 4 years ago

Adding a named range to a file results in read errors in Excel. It seems that Excel requires definedNames to appear before calcPr in workbook.xml, but xlnt switches the order. Here is an example that causes the error: image

Changing the order in xlsx_producer.cpp fixes the problem, but I may have messed something else up in making my changes: image

Also, Excel seems to require absolute cell references ($) in named ranges, so an enhancement might be to modify wb.create_named_range() to ensure that.