Debao Zhang
10 years ago
1 changed files with 33 additions and 12 deletions
@ -1,32 +1,53 @@ |
|||||
#include <QtCore> |
#include <QtCore> |
||||
#include "xlsxdocument.h" |
#include "xlsxdocument.h" |
||||
|
#include "xlsxabstractsheet.h" |
||||
|
|
||||
|
QTXLSX_USE_NAMESPACE |
||||
|
|
||||
int main() |
int main() |
||||
{ |
{ |
||||
QXlsx::Document xlsx; |
//![Create a xlsx file]
|
||||
|
Document xlsx; |
||||
|
|
||||
for (int i=1; i<20; ++i) { |
for (int i=1; i<20; ++i) { |
||||
for (int j=1; j<15; ++j) |
for (int j=1; j<15; ++j) |
||||
xlsx.write(i, j, QString("R %1 C %2").arg(i).arg(j)); |
xlsx.write(i, j, QString("R %1 C %2").arg(i).arg(j)); |
||||
} |
} |
||||
xlsx.renameSheet("Sheet1", "TheFirstSheet"); |
xlsx.addSheet(); |
||||
|
|
||||
xlsx.addSheet("TheSecondSheet"); |
|
||||
xlsx.write(2, 2, "Hello Qt Xlsx"); |
xlsx.write(2, 2, "Hello Qt Xlsx"); |
||||
|
xlsx.addSheet(); |
||||
|
xlsx.write(3, 3, "This will be deleted..."); |
||||
|
|
||||
xlsx.copySheet("TheFirstSheet", "CopyOfTheFirst"); |
xlsx.addSheet("HiddenSheet"); |
||||
|
xlsx.currentSheet()->setHidden(true); |
||||
|
xlsx.write("A1", "This sheet is hidden."); |
||||
|
|
||||
xlsx.addSheet("TheForthSheet"); |
xlsx.addSheet("VeryHiddenSheet"); |
||||
xlsx.write(3, 3, "This will be deleted..."); |
xlsx.sheet("VeryHiddenSheet")->setSheetState(AbstractSheet::SS_VeryHidden); |
||||
|
xlsx.write("A1", "This sheet is very hidden."); |
||||
|
|
||||
|
xlsx.save();//Default name is "Book1.xlsx"
|
||||
|
//![Create a xlsx file]
|
||||
|
|
||||
|
Document xlsx2("Book1.xlsx"); |
||||
|
//![add_copy_move_delete]
|
||||
|
xlsx2.renameSheet("Sheet1", "TheFirstSheet"); |
||||
|
|
||||
|
xlsx2.copySheet("TheFirstSheet", "CopyOfTheFirst"); |
||||
|
|
||||
xlsx.selectSheet("CopyOfTheFirst"); |
xlsx2.selectSheet("CopyOfTheFirst"); |
||||
xlsx.write(25, 2, "On the Copy Sheet"); |
xlsx2.write(25, 2, "On the Copy Sheet"); |
||||
|
|
||||
xlsx.deleteSheet("TheForthSheet"); |
xlsx2.deleteSheet("Sheet3"); |
||||
|
|
||||
xlsx.moveSheet("TheSecondSheet", 0); |
xlsx2.moveSheet("Sheet2", 0); |
||||
|
//![add_copy_move_delete]
|
||||
|
|
||||
xlsx.save(); |
//![show_hidden_sheets]
|
||||
|
xlsx2.sheet("HiddenSheet")->setVisible(true); |
||||
|
xlsx2.sheet("VeryHiddenSheet")->setVisible(true); |
||||
|
//![show_hidden_sheets]
|
||||
|
|
||||
|
xlsx2.saveAs("Book2.xlsx"); |
||||
return 0; |
return 0; |
||||
} |
} |
||||
|
Loading…
Reference in new issue