mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
instead of always writing at least one style, don't write cellStyleXfs and cellStyles at all when there are no styles defined
This commit is contained in:
parent
101c36802e
commit
89be3d83df
@ -1129,7 +1129,8 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
}
|
||||
|
||||
// Style XFs
|
||||
if (stylesheet.style_impls.size() > 0) {
|
||||
if (stylesheet.style_impls.size() > 0)
|
||||
{
|
||||
write_start_element(xmlns, "cellStyleXfs");
|
||||
write_attribute("count", stylesheet.style_impls.size());
|
||||
|
||||
@ -1227,19 +1228,6 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
|
||||
write_end_element(xmlns, "cellStyleXfs");
|
||||
}
|
||||
else
|
||||
{
|
||||
// need minimun one style
|
||||
write_start_element(xmlns, "cellStyleXfs");
|
||||
write_attribute("count", "1");
|
||||
write_start_element(xmlns, "xf");
|
||||
write_attribute("numFmtId", "0");
|
||||
write_attribute("fontId", "0");
|
||||
write_attribute("fillId", "0");
|
||||
write_attribute("borderId", "0");
|
||||
write_end_element(xmlns, "xf");
|
||||
write_end_element(xmlns, "cellStyleXfs");
|
||||
}
|
||||
|
||||
// Format XFs
|
||||
|
||||
@ -1354,7 +1342,8 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
write_end_element(xmlns, "cellXfs");
|
||||
|
||||
// Styles
|
||||
if ( stylesheet.style_impls.size() > 0) {
|
||||
if (stylesheet.style_impls.size() > 0)
|
||||
{
|
||||
write_start_element(xmlns, "cellStyles");
|
||||
write_attribute("count", stylesheet.style_impls.size());
|
||||
std::size_t style_index = 0;
|
||||
@ -1388,18 +1377,6 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
||||
|
||||
write_end_element(xmlns, "cellStyles");
|
||||
}
|
||||
else
|
||||
{
|
||||
// one cell style minimun
|
||||
write_start_element(xmlns, "cellStyles");
|
||||
write_attribute("count", "1");
|
||||
write_start_element(xmlns, "cellStyle");
|
||||
write_attribute("xfId", "0");
|
||||
write_attribute("builtinId", "0");
|
||||
write_attribute("name", "Normal");
|
||||
write_end_element(xmlns, "cellStyle");
|
||||
write_end_element(xmlns, "cellStyles");
|
||||
}
|
||||
|
||||
write_start_element(xmlns, "dxfs");
|
||||
write_attribute("count", "0");
|
||||
|
Loading…
x
Reference in New Issue
Block a user