Qt设置Excel列类型的问题

Areslp Areslp 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我有一组电话号码需要写入Excel,采用QAxObject的方法,但是不知道为什么设置NumberFormatLocal为文本格式不成功。代码片段如下:
			QAxObject * range = worksheet->querySubObject("Cells(int,int)", i+1, 1);  //得到单元格
if (!range)
{
qDebug()<<"range does not exist";
}
QVariant tel=QString("%1").arg(record["tel"].toString()); //02883120983,0开头的电话号码
//qDebug()<<tel;
range->setProperty("Value", tel.toString());
range->dynamicCall("SetNumberFormatLocal(const QVariant&)", QVariant("@"));
//qDebug()<<"NumberFormatLocal:"<<range->property("NumberFormatLocal").toString(); //输出"@"
//qDebug()<<"NumberFormat:"<<range->property("NumberFormat").toString();//输出"@"
range->clear();
range = worksheet->querySubObject("Cells(int,int)", i+1, 2); //另外一个cell
//range->dynamicCall("SetValue(const QVariant&)", record["location"]);
range->setProperty("Value", record["location"]);
range->clear();

但是保存为Excel之后,打开文件,所有单元格都是常规。。就像设置"@"没起作用一样
机器上Office是2007,保存的是xlsx文件
...全文
评论 1
收藏 已收藏
分享
返回顶部
Areslp
Qt 21,503 成员 26,693 内容