QtXlsxWriter icon indicating copy to clipboard operation
QtXlsxWriter copied to clipboard

Some minor and major issues w/ QtXlsx

Open mhkelley opened this issue 5 years ago • 5 comments

Have just started using QtXlsx ( ! nice job ! ) but am having some issues. It is likely that I will be able to fix some of them but almost certainly not all of them. Please let me know what level of interest there would be in addressing some of these. They may be related to known issues, but I couldn't find any relevant info. There may also be existing work-arounds, in which case I'd be thrilled to learn of them.

  1. At present, the package only supports "int" integer values from spreadsheets - Excel supports "long long" integers. This can be resolved by a simple change in xlsxworksheet.cpp. In the routine WorksheetPrivate::loadXmlColumnsInfo, the QVariant cell value is set with

cell->d_func()->value = value.toInt();

Changing that to

cell->d_func()->value = value.toLongLong();

resolves the big integer problem.

  1. Formulas don't seem to be working correctly. There is a fair bit of code to deal with them, but as near as I can tell, formulas are effectively just ignored.

  2. DateTime values are also not dealt with effectively. I figured out a workaround by noting which actual "double" values are really days through the cell format (isDateTimeFormat() seems correct).

  3. Generally, the output file from QtXlsx is not readable by Excel. Excel reports that there are errors (apparently in the sheetn.xml parts), which can coarsely be fixed. The fixes are not perfect, but has let me continue to make some progress in my present tasks.

Thanks

mhkelley avatar Mar 26 '19 19:03 mhkelley

  1. Good point, should also apply on the reading side, will implement as soon as I have a spared minute
  2. Can you provide a minimal example so I can investigate the problem?
  3. Depends what methods you use. The workbooks/worksheets read() methods should handle datetimes correctly. Cell has a method isDateTime to detect if the double it contains it is a date or not
  4. see point 2

VSRonin avatar Mar 27 '19 07:03 VSRonin

Sorry for the length of this email. I thought some of the issues were worth being fairly detailed in what I had learned. I address you questions not quite in order, but have attempted to make it explicitly clear what I address where.

Thank you very much for your assistance thus far.

Mike Kelley

  1. Good point, should also apply on the reading side, will

implement as soon as I have a spared minute

(qint to qlonglong)

The examples I provide below were done using a version where I have already addressed this issue.

  1. see point 2

(problems saving documents)

Haven't yet sorted out all the details but the simplest program I could think of produces an output that fails. The attached file simpletest.cpp (open existing workbook than do a "saveAs") should demonstrate the problem. It looks for an input file (workingdir/testin-1.xlsx) and creates and output file (testout-1.xlsx). Note that it is only as a convenience for me that I've collected all the .xlsx files in to a subdirectory (workingdir) of where my project source is.

Excel discovers some anomaly in the "workbook" xml file and can't recover from that - opens to an workbook with one empty sheet. BTW, When I got started with the exercise to create a simple example, this example worked correctly. I do not know what significant has changed - but A LOT has changed in the interim. Just don't know what that was important. A big change is that I've gone back to the original, as-downloaded, sources. When this example worked, it was using sources that I had monkeyed with substantially. I have made quite a few modifications to the source code in my attempts to figure out what isn't working correctly. Everything in this summary was using a library built with the original source, but with the QInt/QLongLong change implemented.

  1. Can you provide a minimal example so I can investigate the

problem?

(formulas)

Well, it depends on what you mean by "minimal". The examples I provide look at first glance to be a bit involved, but are actually pretty simple.

The second program attached is test.cpp.

By default, test looks for input named testall-in.xlsx and writes testall-out.xlsx, again both in "workingdir". It accepts up to two arguments. If one argument, say xxxx, it looks for input file xxxx-in.xlsx and writes xxxx-out.xlsx, both in "workingdir". If passed a second argument, say yyyy, it produces the output file yyyy-out.xlsx.

In summary, test has two subroutines. ReadXLSX reads an xlsx file. but in doing so builds a vector of vectors of cell contents. I typedefed a user type (struct tSheet) that has a name and a tVecRow of rows. tVecRow is a QVector of tVecCol, which is in turn a QVector of tCells. A tCell (heh heh because it's killing me) which is a user-defined struct with a QVariant, a QXlsx::CellFormula, and a QXlsx::Format). readXLSX loops through the Worksheet to build tSheet.

The second routine is writeXLSX, to which tSheet is passed as an argument. It creates a new QXlsx::Document, adds a sheet, loops through the tSheet and writes the appropriate cells. If the tCell is a formula, it writes the formula. If not, writes the QVariant. In both cases, attempts to write with the Format saved by readXLSX.

I have attached two input files (testall-in.xlsx and testall-1-in.xlsx) and their corresponding output files. I cannot open either output file with EXCEL without errors, but unlike before, both DO give a helpful worksheet.

The difference between testall and testall-1 is interesting and highlights two important necessary fixes. First, Column "D" starts off with several "dummy" entries - that's because it seems that any empty cells within the "dimension()" of the sheet cause program failure. The second is that while the two -in files appear equivalent, they are not. I created testall by cutting/pasting all the formulas. As you'll see in testall-out, most of them failed - that was the origin of my claim that formulas generally don't work. On the other hand, with testall-1 all the formulas are treated correctly. The difference is that in the second, I typed all the formulas directly.

Examination of the input xml file shows the problem directly. Cell C9 has a formula that looks more-or-less normal. However, it is marked as "shared" with a "share index" of 0. Cell C9 notes that it is a "shared formula, and that it is using the formula at "share index" 0.

I fear that I will continue to have serious issues with QtXlxs until both of these issues are resolved - 1) properly handling empty cells and 2) dealing with "shared formulas.

  1. Depends what methods you use. The workbooks/worksheets read()

methods should handle datetimes correctly. Cell has a method

isDateTime to detect if the double it contains it is a date

or not

(DateTime)

Shortly after initially reporting this issue, I recognized that I could leverage isDateTime for a reasonable work-around. However, I do not understand why the date formats do not propagate to the output file. Because I make pretty heavy use of DateTime (mostly dates) I would very much prefer to take advantage of QDate and/or QDateTime directly in the xml parser instead of having to patch it on after the fact in other apps.

Summary:

I have a (sort of) working version of the package that at least mostly addresses these issues.

Specifically I have:

  • replaced QInt values with QLongLong.

  • kludged up a way to handle the shared formulas, but there must be a more proper way to do this. What I do is store the indexed formulas, then manual update the row numbers for subsequent uses. That is guaranteed to fail in normal use, because it is not always possible to understand the spatial relationship of subsequent users to the initial cell location. Simply updating row numbers (instead of for example column numbers) is appropriate for my examples, but not in general.

  • done a course implementation of QDateTime

  • complete failed at figuring out why I cannot open the saved worksheets.

Thank you very much for any insight you might provide and suggestions for how best to proceed.

One final difficulty - I have been completely unable to use the debugging capability in Qt Creator with this library. Every other library I have built/used has allowed this, but not QtXlsx. Somehow, I haven't correctly told the debugger how to find the source files and associate them with the executing library.

From: Luca [email protected] Sent: Wednesday, March 27, 2019 1:47 AM To: VSRonin/QtXlsxWriter [email protected] Cc: mhkelley [email protected]; Author [email protected] Subject: Re: [VSRonin/QtXlsxWriter] Some minor and major issues w/ QtXlsx (#33)

  1. Good point, should also apply on the reading side, will implement as soon as I have a spared minute
  2. Can you provide a minimal example so I can investigate the problem?
  3. Depends what methods you use. The workbooks/worksheets read() methods should handle datetimes correctly. Cell has a method isDateTime to detect if the double it contains it is a date or not
  4. see point 2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VSRonin/QtXlsxWriter/issues/33#issuecomment-477020077 , or mute the thread https://github.com/notifications/unsubscribe-auth/AezlM5AmcxVWKEKud8TPGq4_0LmNSHhHks5vayHygaJpZM4cMPBC . https://github.com/notifications/beacon/AezlMwYJDxE8C2dwczfBk0urdkCjwOp8ks5vayHygaJpZM4cMPBC.gif

#include "simpletest.hpp" #include #include #include <utils.hpp> #include <myfile.hpp> #include <myconfig.hpp> #include <myerror.hpp> #include <QtCore> #include <QtXlsx/QtXlsx>

int main() { QXlsx::Document xlsx("workkingdir/testin-1.xlsx"); if (xlsx.saveAs("workingdir/testout-1.xlsx")) { std::cout << "xlsx save: success" << std::endl; } else { std::cout << "xlsx save: fail" << std::endl; } return 0; }

#include #include //#include <utils.hpp> //#include <myfile.hpp> //#include <myconfig.hpp> //#include <myerror.hpp> #include <QtCore> #include <QtXlsx/QtXlsx>

#define STR(a) a.toLocal8Bit().constData()

typedef struct { QVariant qvar; QXlsx::CellFormula formula; QXlsx::Format format; } tCell;

typedef QVector<tCell> tVecCol; typedef QVector<tVecCol> tVecRow;

typedef struct { QString name; tVecRow rows; } tSheet;

tSheet readXLSX(QString fname) { QXlsx::Document xlsx(fname); QXlsx::Worksheet *cursheet; QStringList names = xlsx.sheetNames(); int nRows, nCols; tSheet sheet;

sheet.name = names.at(0); std::cout << "sheet name <" << STR(sheet.name) << ">" << std::endl; sheet.rows.clear(); cursheet = xlsx.currentWorksheet(); nRows = cursheet->dimension().rowCount(); nCols = cursheet->dimension().columnCount();

tVecRow rVec; for (int ir=1 ; ir<=nRows ; ir++) { std::cout << "row " << ir << ": " << std::endl;

  tVecCol cVec;
  for (int ic=1 ; ic<=nCols ; ic++)
{
  bool               isdt = false;
  QVariant           var  = cursheet->cellAt(ir,ic)->value();
  QXlsx::Format      format = cursheet->cellAt(ir,ic)->format();
  QXlsx::CellFormula formula;
  QString            valstr = STR(var.toString());
  QString            formatstr = STR(format.numberFormat());
  QString            formulastr="";
  QString valid      = " <no formula> ";

  if (format.isDateTimeFormat()) isdt = true;
  if (cursheet->cellAt(ir,ic)->hasFormula())
    {
      formula = cursheet->cellAt(ir,ic)->formula();
      formulastr = formula.formulaText();
      if (formula.isValid())
	{
	  valid= " <valid formula> ";
	}
      else
	{
	  valid= " <invalid formula> ";
	}
    }
  tCell cell;
  cell.qvar    = cursheet->cellAt(ir,ic)->value();
  cell.format  = cursheet->cellAt(ir,ic)->format();
  cell.formula = formula;
  cVec.push_back(cell);
  std::cout << "   in " << ic << " <" << STR(valstr) << ">";
  if (isdt) std::cout << " <is datetime ";
  std::cout << STR(valid);
  std::cout << "> formula <" << STR(formulastr);
  std::cout << "> format <" << STR(formatstr) << ">" << std::endl;
}
  rVec.push_back(cVec);
  std::cout << std::endl;
}

sheet.rows = rVec; std::cout << "sheet name <" << STR(sheet.name) << "> has " << sheet.rows.count() << " rows" << std::endl;

return sheet; }

void writeXLSX(QString fname, tSheet sheet) { QXlsx::Document xlsx; QXlsx::Worksheet *cursheet;

std::cout << "write file" << std::endl; std::cout << "sheet name <" << STR(sheet.name) << "> has " << sheet.rows.count() << " rows" << std::endl; if (!xlsx.addSheet(sheet.name)) { std::cout << "add sheet <" << STR(sheet.name) << "> failed!!" << std::endl; return; }

cursheet = xlsx.currentWorksheet(); for (int ir=0 ; ir<sheet.rows.count() ; ir++) { tVecCol row = sheet.rows.at(ir); std::cout << "row " << ir << std::endl; for (int ic=0 ; ic<row.count() ; ic++) { tCell cell = row.at(ic); QString valstr = cell.qvar.toString(); QString formatstr = cell.format.numberFormat(); QString formulastr = ""; bool isdt = false; bool success = true; QString valid = " "; if (cell.format.isDateTimeFormat()) isdt = true;

  if (cell.formula.isValid())
    {
      formulastr = cell.formula.formulaText();
      valid= " <valid formula> ";
    }

  if (cell.formula.isValid())
    {
      if (!cursheet->writeFormula(ir+1, ic+1, cell.formula, cell.format)) success = false;
    }
  else
    {
      if (!cursheet->write(ir+1, ic+1, cell.qvar, cell.format)) success = false;
    }

  std::cout << "  out " << ic << " <" << STR(valstr) << ">";
  if (isdt) std::cout << " <is datetime ";
  std::cout << STR(valid);
  std::cout << "> formula <" << STR(formulastr);
  std::cout << "> format <" << STR(formatstr) << ">";

  if (!success) std::cout << " failure";
  std::cout << std::endl;
}
}

if (!xlsx.saveAs(fname)) { std::cout << "error writing file <" << STR(fname) << ">" << std::endl; }

return; }

int main(int argc, char *argv[]) { QString workdir = "workingdir/"; QString inname = "testall"; QString outname = "testall";

if (argc > 1) { inname = argv[1]; outname = argv[1]; } if (argc > 2) outname = argv[2];

inname.append("-in.xlsx"); outname.append("-out.xlsx");

inname.prepend(workdir); outname.prepend(workdir);

std::cout << "<" << STR(inname) << "><" << STR(outname) << ">" << std::endl;;

tSheet sheet = readXLSX (inname); writeXLSX (outname, sheet); return 0; }

mhkelley avatar Mar 28 '19 03:03 mhkelley

P.S. – after composing this summary, I went back and tried the two testall input files using the library I modified. EXCEL complains about testall-out.xlsx, but DOES NOT complain about testall-1-out.xlsx. Apparently, one of the changes I made fixed that issue. I guess now I have the obligation of going back and see what all I changed and which of them might have been the important change. Oh well … MHK

Sorry for the length of this email. I thought some of the issues were worth being fairly detailed in what I had learned. I address you questions not quite in order, but have attempted to make it explicitly clear what I address where.

Thank you very much for your assistance thus far.

Mike Kelley

  1. Good point, should also apply on the reading side, will

implement as soon as I have a spared minute

(qint to qlonglong)

The examples I provide below were done using a version where I have already addressed this issue.

  1. see point 2

(problems saving documents)

Haven't yet sorted out all the details but the simplest program I could think of produces an output that fails. The attached file simpletest.cpp (open existing workbook than do a "saveAs") should demonstrate the problem. It looks for an input file (workingdir/testin-1.xlsx) and creates and output file (testout-1.xlsx). Note that it is only as a convenience for me that I've collected all the .xlsx files in to a subdirectory (workingdir) of where my project source is.

Excel discovers some anomaly in the "workbook" xml file and can't recover from that - opens to an workbook with one empty sheet. BTW, When I got started with the exercise to create a simple example, this example worked correctly. I do not know what significant has changed - but A LOT has changed in the interim. Just don't know what that was important. A big change is that I've gone back to the original, as-downloaded, sources. When this example worked, it was using sources that I had monkeyed with substantially. I have made quite a few modifications to the source code in my attempts to figure out what isn't working correctly. Everything in this summary was using a library built with the original source, but with the QInt/QLongLong change implemented.

  1. Can you provide a minimal example so I can investigate the

problem?

(formulas)

Well, it depends on what you mean by "minimal". The examples I provide look at first glance to be a bit involved, but are actually pretty simple.

The second program attached is test.cpp.

By default, test looks for input named testall-in.xlsx and writes testall-out.xlsx, again both in "workingdir". It accepts up to two arguments. If one argument, say xxxx, it looks for input file xxxx-in.xlsx and writes xxxx-out.xlsx, both in "workingdir". If passed a second argument, say yyyy, it produces the output file yyyy-out.xlsx.

In summary, test has two subroutines. ReadXLSX reads an xlsx file. but in doing so builds a vector of vectors of cell contents. I typedefed a user type (struct tSheet) that has a name and a tVecRow of rows. tVecRow is a QVector of tVecCol, which is in turn a QVector of tCells. A tCell (heh heh because it's killing me) which is a user-defined struct with a QVariant, a QXlsx::CellFormula, and a QXlsx::Format). readXLSX loops through the Worksheet to build tSheet.

The second routine is writeXLSX, to which tSheet is passed as an argument. It creates a new QXlsx::Document, adds a sheet, loops through the tSheet and writes the appropriate cells. If the tCell is a formula, it writes the formula. If not, writes the QVariant. In both cases, attempts to write with the Format saved by readXLSX.

I have attached two input files (testall-in.xlsx and testall-1-in.xlsx) and their corresponding output files. I cannot open either output file with EXCEL without errors, but unlike before, both DO give a helpful worksheet.

The difference between testall and testall-1 is interesting and highlights two important necessary fixes. First, Column "D" starts off with several "dummy" entries - that's because it seems that any empty cells within the "dimension()" of the sheet cause program failure. The second is that while the two -in files appear equivalent, they are not. I created testall by cutting/pasting all the formulas. As you'll see in testall-out, most of them failed - that was the origin of my claim that formulas generally don't work. On the other hand, with testall-1 all the formulas are treated correctly. The difference is that in the second, I typed all the formulas directly.

Examination of the input xml file shows the problem directly. Cell C9 has a formula that looks more-or-less normal. However, it is marked as "shared" with a "share index" of 0. Cell C9 notes that it is a "shared formula, and that it is using the formula at "share index" 0.

I fear that I will continue to have serious issues with QtXlxs until both of these issues are resolved - 1) properly handling empty cells and 2) dealing with "shared formulas.

  1. Depends what methods you use. The workbooks/worksheets read()

methods should handle datetimes correctly. Cell has a method

isDateTime to detect if the double it contains it is a date

or not

(DateTime)

Shortly after initially reporting this issue, I recognized that I could leverage isDateTime for a reasonable work-around. However, I do not understand why the date formats do not propagate to the output file. Because I make pretty heavy use of DateTime (mostly dates) I would very much prefer to take advantage of QDate and/or QDateTime directly in the xml parser instead of having to patch it on after the fact in other apps.

Summary:

I have a (sort of) working version of the package that at least mostly addresses these issues.

Specifically I have:

  • replaced QInt values with QLongLong.

  • kludged up a way to handle the shared formulas, but there must be a more proper way to do this. What I do is store the indexed formulas, then manual update the row numbers for subsequent uses. That is guaranteed to fail in normal use, because it is not always possible to understand the spatial relationship of subsequent users to the initial cell location. Simply updating row numbers (instead of for example column numbers) is appropriate for my examples, but not in general.

  • done a course implementation of QDateTime

  • complete failed at figuring out why I cannot open the saved worksheets.

Thank you very much for any insight you might provide and suggestions for how best to proceed.

One final difficulty - I have been completely unable to use the debugging capability in Qt Creator with this library. Every other library I have built/used has allowed this, but not QtXlsx. Somehow, I haven't correctly told the debugger how to find the source files and associate them with the executing library.

From: Luca [email protected] Sent: Wednesday, March 27, 2019 1:47 AM To: VSRonin/QtXlsxWriter [email protected] Cc: mhkelley [email protected]; Author [email protected] Subject: Re: [VSRonin/QtXlsxWriter] Some minor and major issues w/ QtXlsx (#33)

  1. Good point, should also apply on the reading side, will implement as soon as I have a spared minute
  2. Can you provide a minimal example so I can investigate the problem?
  3. Depends what methods you use. The workbooks/worksheets read() methods should handle datetimes correctly. Cell has a method isDateTime to detect if the double it contains it is a date or not
  4. see point 2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VSRonin/QtXlsxWriter/issues/33#issuecomment-477020077 , or mute the thread https://github.com/notifications/unsubscribe-auth/AezlM5AmcxVWKEKud8TPGq4_0LmNSHhHks5vayHygaJpZM4cMPBC . https://github.com/notifications/beacon/AezlMwYJDxE8C2dwczfBk0urdkCjwOp8ks5vayHygaJpZM4cMPBC.gif

mhkelley avatar Mar 28 '19 05:03 mhkelley

PPS – dang I hate acting stupid!! 1) The simpletest routine actually works just find if I spell “workingdir” correctly!! And 2) the it was my reading of cell data, not the cellAt(row,column) that caused the problem with empty cells. I had assumed that cellAt would return a pointer to an empty cell instead of a NULL pointer when it encountered an empty cell. It was easy to overcome that issue, but I think I might prefer the empty cell to the NULL pointer – it’s a bother to always have to check whether the cell exists or not. I’m pretty sure that for EXCEL proper, both the app and VBA modules, treads empty cells very gracefully – much nicer for the user. - MHK

P.S. – after composing this summary, I went back and tried the two testall input files using the library I modified. EXCEL complains about testall-out.xlsx, but DOES NOT complain about testall-1-out.xlsx. Apparently, one of the changes I made fixed that issue. I guess now I have the obligation of going back and see what all I changed and which of them might have been the important change. Oh well … MHK

Sorry for the length of this email. I thought some of the issues were worth being fairly detailed in what I had learned. I address you questions not quite in order, but have attempted to make it explicitly clear what I address where.

Thank you very much for your assistance thus far.

Mike Kelley

  1. Good point, should also apply on the reading side, will

implement as soon as I have a spared minute

(qint to qlonglong)

The examples I provide below were done using a version where I have already addressed this issue.

  1. see point 2

(problems saving documents)

Haven't yet sorted out all the details but the simplest program I could think of produces an output that fails. The attached file simpletest.cpp (open existing workbook than do a "saveAs") should demonstrate the problem. It looks for an input file (workingdir/testin-1.xlsx) and creates and output file (testout-1.xlsx). Note that it is only as a convenience for me that I've collected all the .xlsx files in to a subdirectory (workingdir) of where my project source is.

Excel discovers some anomaly in the "workbook" xml file and can't recover from that - opens to an workbook with one empty sheet. BTW, When I got started with the exercise to create a simple example, this example worked correctly. I do not know what significant has changed - but A LOT has changed in the interim. Just don't know what that was important. A big change is that I've gone back to the original, as-downloaded, sources. When this example worked, it was using sources that I had monkeyed with substantially. I have made quite a few modifications to the source code in my attempts to figure out what isn't working correctly. Everything in this summary was using a library built with the original source, but with the QInt/QLongLong change implemented.

  1. Can you provide a minimal example so I can investigate the

problem?

(formulas)

Well, it depends on what you mean by "minimal". The examples I provide look at first glance to be a bit involved, but are actually pretty simple.

The second program attached is test.cpp.

By default, test looks for input named testall-in.xlsx and writes testall-out.xlsx, again both in "workingdir". It accepts up to two arguments. If one argument, say xxxx, it looks for input file xxxx-in.xlsx and writes xxxx-out.xlsx, both in "workingdir". If passed a second argument, say yyyy, it produces the output file yyyy-out.xlsx.

In summary, test has two subroutines. ReadXLSX reads an xlsx file. but in doing so builds a vector of vectors of cell contents. I typedefed a user type (struct tSheet) that has a name and a tVecRow of rows. tVecRow is a QVector of tVecCol, which is in turn a QVector of tCells. A tCell (heh heh because it's killing me) which is a user-defined struct with a QVariant, a QXlsx::CellFormula, and a QXlsx::Format). readXLSX loops through the Worksheet to build tSheet.

The second routine is writeXLSX, to which tSheet is passed as an argument. It creates a new QXlsx::Document, adds a sheet, loops through the tSheet and writes the appropriate cells. If the tCell is a formula, it writes the formula. If not, writes the QVariant. In both cases, attempts to write with the Format saved by readXLSX.

I have attached two input files (testall-in.xlsx and testall-1-in.xlsx) and their corresponding output files. I cannot open either output file with EXCEL without errors, but unlike before, both DO give a helpful worksheet.

The difference between testall and testall-1 is interesting and highlights two important necessary fixes. First, Column "D" starts off with several "dummy" entries - that's because it seems that any empty cells within the "dimension()" of the sheet cause program failure. The second is that while the two -in files appear equivalent, they are not. I created testall by cutting/pasting all the formulas. As you'll see in testall-out, most of them failed - that was the origin of my claim that formulas generally don't work. On the other hand, with testall-1 all the formulas are treated correctly. The difference is that in the second, I typed all the formulas directly.

Examination of the input xml file shows the problem directly. Cell C9 has a formula that looks more-or-less normal. However, it is marked as "shared" with a "share index" of 0. Cell C9 notes that it is a "shared formula, and that it is using the formula at "share index" 0.

I fear that I will continue to have serious issues with QtXlxs until both of these issues are resolved - 1) properly handling empty cells and 2) dealing with "shared formulas.

  1. Depends what methods you use. The workbooks/worksheets read()

methods should handle datetimes correctly. Cell has a method

isDateTime to detect if the double it contains it is a date

or not

(DateTime)

Shortly after initially reporting this issue, I recognized that I could leverage isDateTime for a reasonable work-around. However, I do not understand why the date formats do not propagate to the output file. Because I make pretty heavy use of DateTime (mostly dates) I would very much prefer to take advantage of QDate and/or QDateTime directly in the xml parser instead of having to patch it on after the fact in other apps.

Summary:

I have a (sort of) working version of the package that at least mostly addresses these issues.

Specifically I have:

  • replaced QInt values with QLongLong.

  • kludged up a way to handle the shared formulas, but there must be a more proper way to do this. What I do is store the indexed formulas, then manual update the row numbers for subsequent uses. That is guaranteed to fail in normal use, because it is not always possible to understand the spatial relationship of subsequent users to the initial cell location. Simply updating row numbers (instead of for example column numbers) is appropriate for my examples, but not in general.

  • done a course implementation of QDateTime

  • complete failed at figuring out why I cannot open the saved worksheets.

Thank you very much for any insight you might provide and suggestions for how best to proceed.

One final difficulty - I have been completely unable to use the debugging capability in Qt Creator with this library. Every other library I have built/used has allowed this, but not QtXlsx. Somehow, I haven't correctly told the debugger how to find the source files and associate them with the executing library.

From: Luca [email protected] Sent: Wednesday, March 27, 2019 1:47 AM To: VSRonin/QtXlsxWriter [email protected] Cc: mhkelley [email protected]; Author [email protected] Subject: Re: [VSRonin/QtXlsxWriter] Some minor and major issues w/ QtXlsx (#33)

  1. Good point, should also apply on the reading side, will implement as soon as I have a spared minute
  2. Can you provide a minimal example so I can investigate the problem?
  3. Depends what methods you use. The workbooks/worksheets read() methods should handle datetimes correctly. Cell has a method isDateTime to detect if the double it contains it is a date or not
  4. see point 2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VSRonin/QtXlsxWriter/issues/33#issuecomment-477020077 , or mute the thread https://github.com/notifications/unsubscribe-auth/AezlM5AmcxVWKEKud8TPGq4_0LmNSHhHks5vayHygaJpZM4cMPBC . https://github.com/notifications/beacon/AezlMwYJDxE8C2dwczfBk0urdkCjwOp8ks5vayHygaJpZM4cMPBC.gif

mhkelley avatar Mar 28 '19 18:03 mhkelley

Hi Everybody , There is a QtExcel/QXlsx project base on dbzhang800/QtXlsxWriter, but it is developed https://github.com/QtExcel/QXlsx A lot of error was fixed . maybe ,you will interested on it .

liufeijin avatar Mar 29 '19 13:03 liufeijin