API change: Using Format instead of Format *
This commit is contained in:
+47
-47
@@ -8,17 +8,17 @@ QTXLSX_USE_NAMESPACE
|
||||
|
||||
void writeHorizontalAlignCell(Document &xlsx, const QString &cell, const QString &text, Format::HorizontalAlignment align)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setHorizontalAlignment(align);
|
||||
format->setBorderStyle(Format::BorderThin);
|
||||
Format format;
|
||||
format.setHorizontalAlignment(align);
|
||||
format.setBorderStyle(Format::BorderThin);
|
||||
xlsx.write(cell, text, format);
|
||||
}
|
||||
|
||||
void writeVerticalAlignCell(Document &xlsx, const QString &range, const QString &text, Format::VerticalAlignment align)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setVerticalAlignment(align);
|
||||
format->setBorderStyle(Format::BorderThin);
|
||||
Format format;
|
||||
format.setVerticalAlignment(align);
|
||||
format.setBorderStyle(Format::BorderThin);
|
||||
CellRange r(range);
|
||||
xlsx.write(r.firstRow(), r.firstColumn(), text);
|
||||
xlsx.mergeCells(r, format);
|
||||
@@ -26,54 +26,54 @@ void writeVerticalAlignCell(Document &xlsx, const QString &range, const QString
|
||||
|
||||
void writeBorderStyleCell(Document &xlsx, const QString &cell, const QString &text, Format::BorderStyle bs)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setBorderStyle(bs);
|
||||
Format format;
|
||||
format.setBorderStyle(bs);
|
||||
xlsx.write(cell, text, format);
|
||||
}
|
||||
|
||||
void writeSolidFillCell(Document &xlsx, const QString &cell, const QColor &color)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setPatternBackgroundColor(color);
|
||||
Format format;
|
||||
format.setPatternBackgroundColor(color);
|
||||
xlsx.write(cell, QVariant(), format);
|
||||
}
|
||||
|
||||
void writePatternFillCell(Document &xlsx, const QString &cell, Format::FillPattern pattern, const QColor &color)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setPatternForegroundColor(color);
|
||||
format->setFillPattern(pattern);
|
||||
Format format;
|
||||
format.setPatternForegroundColor(color);
|
||||
format.setFillPattern(pattern);
|
||||
xlsx.write(cell, QVariant(), format);
|
||||
}
|
||||
|
||||
void writeBorderAndFontColorCell(Document &xlsx, const QString &cell, const QString &text, const QColor &color)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setBorderStyle(Format::BorderThin);
|
||||
format->setBorderColor(color);
|
||||
format->setFontColor(color);
|
||||
Format format;
|
||||
format.setBorderStyle(Format::BorderThin);
|
||||
format.setBorderColor(color);
|
||||
format.setFontColor(color);
|
||||
xlsx.write(cell, text, format);
|
||||
}
|
||||
|
||||
void writeFontNameCell(Document &xlsx, const QString &cell, const QString &text)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setFontName(text);
|
||||
format->setFontSize(16);
|
||||
Format format;
|
||||
format.setFontName(text);
|
||||
format.setFontSize(16);
|
||||
xlsx.write(cell, text, format);
|
||||
}
|
||||
|
||||
void writeFontSizeCell(Document &xlsx, const QString &cell, int size)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setFontSize(size);
|
||||
Format format;
|
||||
format.setFontSize(size);
|
||||
xlsx.write(cell, "Qt Xlsx", format);
|
||||
}
|
||||
|
||||
void writeInternalNumFormatsCell(Document &xlsx, int row, double value, int numFmt)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setNumberFormatIndex(numFmt);
|
||||
Format format;
|
||||
format.setNumberFormatIndex(numFmt);
|
||||
xlsx.write(row, 1, value);
|
||||
xlsx.write(row, 2, QString("Builtin NumFmt %1").arg(numFmt));
|
||||
xlsx.write(row, 3, value, format);
|
||||
@@ -81,8 +81,8 @@ void writeInternalNumFormatsCell(Document &xlsx, int row, double value, int numF
|
||||
|
||||
void writeCustomNumFormatsCell(Document &xlsx, int row, double value, const QString &numFmt)
|
||||
{
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setNumberFormat(numFmt);
|
||||
Format format;
|
||||
format.setNumberFormat(numFmt);
|
||||
xlsx.write(row, 1, value);
|
||||
xlsx.write(row, 2, numFmt);
|
||||
xlsx.write(row, 3, value, format);
|
||||
@@ -141,17 +141,17 @@ int main()
|
||||
xlsx.addWorksheet("Fonts");
|
||||
|
||||
xlsx.write("B3", "Normal");
|
||||
Format *font_bold = xlsx.createFormat();
|
||||
font_bold->setFontBold(true);
|
||||
Format font_bold;
|
||||
font_bold.setFontBold(true);
|
||||
xlsx.write("B4", "Bold", font_bold);
|
||||
Format *font_italic = xlsx.createFormat();
|
||||
font_italic->setFontItalic(true);
|
||||
Format font_italic;
|
||||
font_italic.setFontItalic(true);
|
||||
xlsx.write("B5", "Italic", font_italic);
|
||||
Format *font_underline = xlsx.createFormat();
|
||||
font_underline->setFontUnderline(Format::FontUnderlineSingle);
|
||||
Format font_underline;
|
||||
font_underline.setFontUnderline(Format::FontUnderlineSingle);
|
||||
xlsx.write("B6", "Underline", font_underline);
|
||||
Format *font_strikeout = xlsx.createFormat();
|
||||
font_strikeout->setFontStrikeOut(true);
|
||||
Format font_strikeout;
|
||||
font_strikeout.setFontStrikeOut(true);
|
||||
xlsx.write("B7", "StrikeOut", font_strikeout);
|
||||
|
||||
writeFontNameCell(xlsx, "D3", "Arial");
|
||||
@@ -170,9 +170,9 @@ int main()
|
||||
writeFontSizeCell(xlsx, "G8", 20);
|
||||
writeFontSizeCell(xlsx, "G9", 25);
|
||||
|
||||
Format *font_vertical = xlsx.createFormat();
|
||||
font_vertical->setRotation(255);
|
||||
font_vertical->setFontSize(16);
|
||||
Format font_vertical;
|
||||
font_vertical.setRotation(255);
|
||||
font_vertical.setFontSize(16);
|
||||
xlsx.write("J3", "vertical", font_vertical);
|
||||
xlsx.mergeCells("J3:J9");
|
||||
|
||||
@@ -180,10 +180,10 @@ int main()
|
||||
//Create the third sheet.
|
||||
xlsx.addWorksheet("Formulas");
|
||||
xlsx.setColumn("A", "B", 40);
|
||||
Format *rAlign = xlsx.createFormat();
|
||||
rAlign->setHorizontalAlignment(Format::AlignRight);
|
||||
Format *lAlign = xlsx.createFormat();
|
||||
lAlign->setHorizontalAlignment(Format::AlignLeft);
|
||||
Format rAlign;
|
||||
rAlign.setHorizontalAlignment(Format::AlignRight);
|
||||
Format lAlign;
|
||||
lAlign.setHorizontalAlignment(Format::AlignLeft);
|
||||
xlsx.write("B3", 40, lAlign);
|
||||
xlsx.write("B4", 30, lAlign);
|
||||
xlsx.write("B5", 50, lAlign);
|
||||
@@ -215,9 +215,9 @@ int main()
|
||||
xlsx.write("A21", "LEN(\"Hello Qt!\")=", rAlign);
|
||||
xlsx.write("B21", "=LEN(\"Hello Qt!\")", lAlign);
|
||||
|
||||
Format *dateFormat = xlsx.createFormat();
|
||||
dateFormat->setHorizontalAlignment(Format::AlignLeft);
|
||||
dateFormat->setNumberFormat("yyyy-mm-dd");
|
||||
Format dateFormat;
|
||||
dateFormat.setHorizontalAlignment(Format::AlignLeft);
|
||||
dateFormat.setNumberFormat("yyyy-mm-dd");
|
||||
xlsx.write("A23", "DATE(2013,8,13)=", rAlign);
|
||||
xlsx.write("B23", "=DATE(2013,8,13)", dateFormat);
|
||||
xlsx.write("A24", "DAY(B23)=", rAlign);
|
||||
@@ -260,9 +260,9 @@ int main()
|
||||
//---------------------------------------------------------------
|
||||
//Create the fifth sheet.
|
||||
xlsx.addWorksheet("Merging");
|
||||
Format *centerAlign = xlsx.createFormat();
|
||||
centerAlign->setHorizontalAlignment(Format::AlignHCenter);
|
||||
centerAlign->setVerticalAlignment(Format::AlignVCenter);
|
||||
Format centerAlign;
|
||||
centerAlign.setHorizontalAlignment(Format::AlignHCenter);
|
||||
centerAlign.setVerticalAlignment(Format::AlignVCenter);
|
||||
xlsx.write("B4", "Hello Qt!");
|
||||
xlsx.mergeCells("B4:F6", centerAlign);
|
||||
xlsx.write("B8", 1);
|
||||
|
||||
@@ -13,10 +13,10 @@ int main()
|
||||
|
||||
//![1]
|
||||
xlsx.setColumn("A", "B", 40);
|
||||
Format *rAlign = xlsx.createFormat();
|
||||
rAlign->setHorizontalAlignment(Format::AlignRight);
|
||||
Format *lAlign = xlsx.createFormat();
|
||||
lAlign->setHorizontalAlignment(Format::AlignLeft);
|
||||
Format rAlign;
|
||||
rAlign.setHorizontalAlignment(Format::AlignRight);
|
||||
Format lAlign;
|
||||
lAlign.setHorizontalAlignment(Format::AlignLeft);
|
||||
xlsx.write("B3", 40, lAlign);
|
||||
xlsx.write("B4", 30, lAlign);
|
||||
xlsx.write("B5", 50, lAlign);
|
||||
|
||||
@@ -7,9 +7,9 @@ int main()
|
||||
{
|
||||
Document xlsx;
|
||||
//![0]
|
||||
Format *format = xlsx.createFormat();
|
||||
format->setHorizontalAlignment(Format::AlignHCenter);
|
||||
format->setVerticalAlignment(Format::AlignVCenter);
|
||||
Format format;
|
||||
format.setHorizontalAlignment(Format::AlignHCenter);
|
||||
format.setVerticalAlignment(Format::AlignVCenter);
|
||||
//![0]
|
||||
//![1]
|
||||
xlsx.write("B4", "Hello Qt!");
|
||||
|
||||
@@ -9,9 +9,9 @@ int main(int argc, char** argv)
|
||||
QXlsx::Document xlsx;
|
||||
xlsx.setColumn(1, 4, 20.0);
|
||||
|
||||
QXlsx::Format *header = xlsx.createFormat();
|
||||
header->setFontBold(true);
|
||||
header->setFontSize(20);
|
||||
QXlsx::Format header;
|
||||
header.setFontBold(true);
|
||||
header.setFontSize(20);
|
||||
|
||||
//Custom number formats
|
||||
QStringList numFormats;
|
||||
@@ -26,8 +26,8 @@ int main(int argc, char** argv)
|
||||
int row = i+2;
|
||||
xlsx.write(row, 1, 100.0);
|
||||
xlsx.write(row, 2, numFormats[i]);
|
||||
QXlsx::Format *format = xlsx.createFormat();
|
||||
format->setNumberFormat(numFormats[i]);
|
||||
QXlsx::Format format;
|
||||
format.setNumberFormat(numFormats[i]);
|
||||
xlsx.write(row, 3, 100.0, format);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ int main(int argc, char** argv)
|
||||
int numFmt = i;
|
||||
xlsx.write(row, 1, 100.0);
|
||||
xlsx.write(row, 2, numFmt);
|
||||
QXlsx::Format *format = xlsx.createFormat();
|
||||
format->setNumberFormatIndex(numFmt);
|
||||
QXlsx::Format format;
|
||||
format.setNumberFormatIndex(numFmt);
|
||||
xlsx.write(row, 3, 100.0, format);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,18 @@ int main()
|
||||
xlsx.setColumn(3, 3, 40.0);
|
||||
|
||||
//Set style for the row 11th.
|
||||
QXlsx::Format *format1 = xlsx.createFormat();
|
||||
format1->setFontBold(true);
|
||||
format1->setFontColor(QColor(Qt::blue));
|
||||
format1->setFontSize(20);
|
||||
QXlsx::Format format1;
|
||||
format1.setFontBold(true);
|
||||
format1.setFontColor(QColor(Qt::blue));
|
||||
format1.setFontSize(20);
|
||||
xlsx.write(11, 1, "Hello Row Style");
|
||||
xlsx.write(11, 6, "Blue Color");
|
||||
xlsx.setRow(11, 41, format1);
|
||||
|
||||
//Set style for the col [9th, 16th)
|
||||
QXlsx::Format *format2 = xlsx.createFormat();
|
||||
format2->setFontBold(true);
|
||||
format2->setFontColor(QColor(Qt::magenta));
|
||||
QXlsx::Format format2;
|
||||
format2.setFontBold(true);
|
||||
format2.setFontColor(QColor(Qt::magenta));
|
||||
for (int row=12; row<=30; row++)
|
||||
for (int col=9; col<=15; col++)
|
||||
xlsx.write(row, col, row+col);
|
||||
|
||||
@@ -5,32 +5,32 @@
|
||||
int main()
|
||||
{
|
||||
QXlsx::Document xlsx;
|
||||
QXlsx::Format *format1 = xlsx.createFormat();
|
||||
format1->setFontColor(QColor(Qt::red));
|
||||
format1->setFontSize(15);
|
||||
format1->setHorizontalAlignment(QXlsx::Format::AlignHCenter);
|
||||
format1->setBorderStyle(QXlsx::Format::BorderDashDotDot);
|
||||
QXlsx::Format format1;
|
||||
format1.setFontColor(QColor(Qt::red));
|
||||
format1.setFontSize(15);
|
||||
format1.setHorizontalAlignment(QXlsx::Format::AlignHCenter);
|
||||
format1.setBorderStyle(QXlsx::Format::BorderDashDotDot);
|
||||
xlsx.write("A1", "Hello Qt!", format1);
|
||||
xlsx.write("B3", 12345, format1);
|
||||
|
||||
QXlsx::Format *format2 = xlsx.createFormat();
|
||||
format2->setFontBold(true);
|
||||
format2->setFontUnderline(QXlsx::Format::FontUnderlineDouble);
|
||||
format2->setFillPattern(QXlsx::Format::PatternLightUp);
|
||||
QXlsx::Format format2;
|
||||
format2.setFontBold(true);
|
||||
format2.setFontUnderline(QXlsx::Format::FontUnderlineDouble);
|
||||
format2.setFillPattern(QXlsx::Format::PatternLightUp);
|
||||
xlsx.write("C5", "=44+33", format2);
|
||||
xlsx.write("D7", true, format2);
|
||||
|
||||
QXlsx::Format *format3 = xlsx.createFormat();
|
||||
format3->setFontBold(true);
|
||||
format3->setFontColor(QColor(Qt::blue));
|
||||
format3->setFontSize(20);
|
||||
QXlsx::Format format3;
|
||||
format3.setFontBold(true);
|
||||
format3.setFontColor(QColor(Qt::blue));
|
||||
format3.setFontSize(20);
|
||||
xlsx.write(11, 1, "Hello Row Style");
|
||||
xlsx.write(11, 6, "Blue Color");
|
||||
xlsx.setRow(11, 41, format3);
|
||||
|
||||
QXlsx::Format *format4 = xlsx.createFormat();
|
||||
format4->setFontBold(true);
|
||||
format4->setFontColor(QColor(Qt::magenta));
|
||||
QXlsx::Format format4;
|
||||
format4.setFontBold(true);
|
||||
format4.setFontColor(QColor(Qt::magenta));
|
||||
for (int row=21; row<=40; row++)
|
||||
for (int col=9; col<16; col++)
|
||||
xlsx.write(row, col, row+col);
|
||||
@@ -38,8 +38,8 @@ int main()
|
||||
|
||||
xlsx.write("A5", QDate(2013, 8, 29));
|
||||
|
||||
QXlsx::Format *format6 = xlsx.createFormat();
|
||||
format6->setPatternBackgroundColor(QColor(Qt::green));
|
||||
QXlsx::Format format6;
|
||||
format6.setPatternBackgroundColor(QColor(Qt::green));
|
||||
xlsx.write("A6", "Background color: green", format6);
|
||||
|
||||
xlsx.saveAs("book1.xlsx");
|
||||
|
||||
Reference in New Issue
Block a user