概述
QAxObject *range = workSheet->querySubObject(“Cells(int,int)”, row, column);
range->dynamicCall(“SetValue(const QVariant&)”, variant);
// QAxObject *interior = range->querySubObject(“Interior”);
// interior->setProperty(“Color”, QColor(0, 255, 0));
// QAxObject *border = range->querySubObject(“Borders”);
// border->setProperty(“Color”, QColor(0, 0, 255));
QAxObject *font = range->querySubObject(“Font”); //获取单元格字体
//font->setProperty(“Name”, QStringLiteral(“华文彩云”)); //设置单元格字体
font->setProperty(“Bold”, true); //设置单元格字体加粗
//font->setProperty(“Size”, 20); //设置单元格字体大小
//font->setProperty(“Italic”, true); //设置单元格字体斜体
//font->setProperty(“Underline”, 2); //设置单元格下划线
font->setProperty(“Color”, QColor(255, 0, 0)); //设置单元格字体颜色(红色)
//设置单元格内容,并合并单元格(第5行第3列-第8行第5列)
QAxObject *cell_5_6 = work_sheet->querySubObject(“Cells(int,int)”, 5, 3);
cell_5_6->setProperty(“Value”, “Java”); //设置单元格值
QAxObject *cell_8_5 = work_sheet->querySubObject(“Cells(int,int)”, 8, 5);
cell_8_5->setProperty(“Value”, “C++”);
QString merge_cell;
merge_cell.append(QChar(3 - 1 + ‘A’)); //初始列
merge_cell.append(QString::number(5)); //初始行
merge_cell.append(“:”);
merge_cell.append(QChar(5 - 1 + ‘A’)); //终止列
merge_cell.append(QString::number(8)); //终止行
QAxObject *merge_range = work_sheet->querySubObject(“Range(const QString&)”, merge_cell);
merge_range->setProperty(“HorizontalAlignment”, -4108);
merge_range->setProperty(“VerticalAlignment”, -4108);
merge_range->setProperty(“WrapText”, true);
merge_range->setProperty(“MergeCells”, true); //合并单元格
//merge_range->setProperty(“MergeCells”, false); //拆分单元格
最后
以上就是鲤鱼跳跳糖为你收集整理的QT设置单元格格式的全部内容,希望文章能够帮你解决QT设置单元格格式所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复