Skip to content

How to check whether the cell has set strikethrough ? #314

@kevin-ma-86

Description

@kevin-ma-86

#section 1:question
For example, cell A3 has set strikethrough while A2 not. I imitate Demo10 to check whether strikethrough has been set , but both A2 and A3 have not strikethrough. they return strikethrough() equal 0.
What should I do? Do anyone offer me the right demo source code. Or the

 The new demo source code as following:

#section 2: demo source code

    OpenXLSX::XLDocument doc;
    doc.open("./Demo11.xlsx");

    std::cout << "Open Demo11.xlsx" << std::endl;

    XLNumberFormats & numberFormats = doc.styles().numberFormats();
    XLFonts & fonts = doc.styles().fonts();
    XLFills & fills = doc.styles().fills();
    XLBorders & borders = doc.styles().borders();
    XLCellFormats & cellStyleFormats = doc.styles().cellStyleFormats();
    XLCellFormats & cellFormats = doc.styles().cellFormats();
    XLCellStyles & cellStyles = doc.styles().cellStyles();

    XLWorksheet wks = doc.workbook().worksheet("Sheet1");
    XLStyleIndex cellFormatIndexA2 = wks.cell("A2").cellFormat();                 // get index of cell format
    XLStyleIndex cellFormatIndexA3 = wks.cell("A3").cellFormat();                 // get index of cell format

    XLStyleIndex fontIndexA2 = cellFormats[ cellFormatIndexA2 ].fontIndex();      // get index of used font
    XLStyleIndex fontIndexA3 = cellFormats[ cellFormatIndexA3 ].fontIndex();      // get index of used font

    cout << "A2 wheter strikethrough:" << fonts[ fontIndexA2 ].strikethrough() << endl;      // strikethrough() is 0
    cout << "A3 wheter strikethrough:" << fonts[ fontIndexA3 ].strikethrough() << endl;       // strikethrough() is 0

#section 3: OpenXLSX info
Dec 23th, 2024.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingresolvedThis issue has been resolved.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions