• 349阅读
  • 0回复

[提问]xlsx 计算公式 [复制链接]

上一主题 下一主题
离线zhouxining
 

只看楼主 倒序阅读 楼主  发表于: 02-11
采用qtxlsxwriter进行xlsx操作,
  QXlsx::Document xlsx("test01.xlsx");     QXlsx::Workbook *workBook = xlsx.workbook();     QXlsx::Worksheet *workSheet = dynamic_cast<QXlsx::Worksheet*>(workBook->sheet(0));     xlsx.write("B1", ui->lineEdit_2->text().toDouble());     xlsx.write("B2", 30);     xlsx.write("B3", 50);     xlsx.write("A4", "SUM(B1:B3)=");     xlsx.write("B4", "=SUM(B1:B3)");
     xlsx.write("A1", "=44+33");     xlsx.save();

     QXlsx::Document xlsx2("test01.xlsx");
     //xlsx2.sheet("SharedFormula")     //QXlsx::Worksheet *sharedFormulaSheet = dynamic_cast<QXlsx::Worksheet*>(workBook->sheet(0));     QXlsx::Worksheet *sharedFormulaSheet = dynamic_cast<QXlsx::Worksheet*>(xlsx2.sheet("Sheet1"));
     QXlsx::Cell *cell = sharedFormulaSheet->cellAt(1,1);     QMessageBox::information(this,tr("220"),cell->value().toString());
     for (int row=1; row<5; ++row) {         cell = sharedFormulaSheet->cellAt(row,2);         QMessageBox::information(this,tr("220"),cell->value().toString());     }
     xlsx2.saveAs("test01.xlsx");问题:公式xlsx.write("B4", "=SUM(B1:B3)"); 公式=SUM(B1:B3)不能计算,但是打开test01.xlsx文件后,在office里面能够直接计算,求大佬告知怎么样才能在QT里面计算
快速回复
限100 字节
 
上一个 下一个