2025-04-07 Demo10: added a disabled use of borders with merged cells

This commit is contained in:
Lars Uffmann 2025-04-07 17:59:19 +02:00
parent 75f9be4e01
commit 48e1b416d0
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions

View File

@ -220,6 +220,7 @@ int main()
myCellRange.setFormat( newCellStyle ); // assign the new format to the full range of cells myCellRange.setFormat( newCellStyle ); // assign the new format to the full range of cells
// ===== BEGIN cell borders demo // ===== BEGIN cell borders demo
XLStyleIndex borderFormat = 0; // scope declaration
{ {
// create a new cell format based on the current C3 format & assign it back to C3 // create a new cell format based on the current C3 format & assign it back to C3
XLStyleIndex borderedCellFormat = cellFormats.create( cellFormats[ wks.cell("C7").cellFormat() ] ); XLStyleIndex borderedCellFormat = cellFormats.create( cellFormats[ wks.cell("C7").cellFormat() ] );
@ -227,7 +228,7 @@ int main()
wks.cell("C7") = "borders demo"; wks.cell("C7") = "borders demo";
// ===== Create a new border format style & assign it to the new cell format // ===== Create a new border format style & assign it to the new cell format
XLStyleIndex borderFormat = borders.create(); borderFormat = borders.create();
// NOTE: the new border format uses a default (empty) borders object to demonstrate OpenXLSX ordered inserts. // NOTE: the new border format uses a default (empty) borders object to demonstrate OpenXLSX ordered inserts.
// Using an existing border style as a template would copy the OpenXLSX default border style which // Using an existing border style as a template would copy the OpenXLSX default border style which
// already contains elements in the correct sequence, so that inserts could not be demonstrated. // already contains elements in the correct sequence, so that inserts could not be demonstrated.
@ -445,7 +446,10 @@ int main()
// output the value of the merge's top left cell // output the value of the merge's top left cell
std::cout << "value of cell F6 by merge is \"" << wks.cell(topLeftRef) << "\"" << std::endl; std::cout << "value of cell F6 by merge is \"" << wks.cell(topLeftRef) << "\"" << std::endl;
} }
wks.cell("E4").setCellFormat( mergedCellFormat ); XLStyleIndex mergedCellFormatWithBorder = cellFormats.create( cellFormats[ mergedCellFormat ] );
if( false ) // enable this if you want to experiment with the borderFormat
cellFormats[ mergedCellFormatWithBorder ].setBorderIndex( borderFormat );
wks.cell("E4").setCellFormat( mergedCellFormatWithBorder );
wks.cell("J5") = "merged red range #2\n - hidden cell contents have been deleted!"; wks.cell("J5") = "merged red range #2\n - hidden cell contents have been deleted!";
wks.mergeCells("J5:L8", XLEmptyHiddenCells); // merge cells with deletion of contents wks.mergeCells("J5:L8", XLEmptyHiddenCells); // merge cells with deletion of contents
wks.cell("J5").setCellFormat( mergedCellFormat ); wks.cell("J5").setCellFormat( mergedCellFormat );

View File

@ -7,6 +7,9 @@ Microsoft Excel® files, with the .xlsx format.
As the heading says - the latest "Release" that is shown on https://github.com/troldal/OpenXLSX/releases is from 2021-11-06, and severely outdated - please pull / download the latest SW version directly from the repository in its current state. Link for those that do not want to use ```git```: https://github.com/troldal/OpenXLSX/archive/refs/heads/master.zip As the heading says - the latest "Release" that is shown on https://github.com/troldal/OpenXLSX/releases is from 2021-11-06, and severely outdated - please pull / download the latest SW version directly from the repository in its current state. Link for those that do not want to use ```git```: https://github.com/troldal/OpenXLSX/archive/refs/heads/master.zip
## (aral-matrix) 07 April 2025 - Demo10: added a disabled use of borders with merged cells
* enable Demo10 line 450 to experiment - but LibreOffice behaves weird (at least) with (diagonal) borders, so I have disabled this Demo functionality by default
## (aral-matrix) 24 March 2025 - XLStyles: XLFont fix attribute values underline, scheme, vertAlign ## (aral-matrix) 24 March 2025 - XLStyles: XLFont fix attribute values underline, scheme, vertAlign
* getters ```XLFont::underline, ::scheme, ::vertAlign```: fix default value to set for attribute val when tag doesn't exist * getters ```XLFont::underline, ::scheme, ::vertAlign```: fix default value to set for attribute val when tag doesn't exist
* setter ```XLFont::setUnderline```: return correct "none" value for XLUnderlineNone from XLUnderlineStyleToString (was returning empty string) * setter ```XLFont::setUnderline```: return correct "none" value for XLUnderlineNone from XLUnderlineStyleToString (was returning empty string)