QXlsx icon indicating copy to clipboard operation
QXlsx copied to clipboard

Possible error in data labels (bar chart)

Open yuritatyanin opened this issue 1 year ago • 0 comments

First, I would like to say “Big thanks” to everyone involved in the direct development of this library :) But I have a few questions about working with diagrams. I use this code in my program:

QXlsx::Chart *barChart = _fileXls.insertChart(3, 3, QSize(600, 300));
barChart->setChartType(QXlsx::Chart::CT_BarChart);
QString range = QString("A5:B%1")
                .arg(5+info.productivityData.size()-1);
barChart->addSeries(QXlsx::CellRange(range),nullptr,true,false,false);

The data table consists of two columns and several rows of data, where the first row is the table title. The result of the library is this: photo_2024-04-18_11-08-06

The expected result is like this: photo_2024-04-18_11-10-25

I started to figure it out and noticed these lines of code from the file xlsxchart.cpp

I commented out this block of code (91-93 line xlsxchart.cpp)

if (headerH) 
{
    firstDataRow += 1;
}

and corrected third argument subRange from range.firstRow() to range.lastRow() (106 line xlsxchart.cpp)

if (headerH) 
{
    CellRange subRange(range.firstRow(), col, range.lastRow(), col);
    series->headerH_numRef =
        sheetName + QLatin1String("!") + subRange.toString(true, true);
} 
else 
{
    series->headerH_numRef = QString();
}

I do not deny that I misunderstood something in the library code, but these edits helped solve my problem, but I did not test other events, etc. And that’s why I didn’t make a pull request, but decided to ask a question) @j2doll

yuritatyanin avatar Apr 18 '24 04:04 yuritatyanin