有时有 Excel 导出问题
Sometimes having Excel export problems
我有问题,我正在导入循环 Table 到 Excel。
我的代码是这样的:
#WINAPI
#Excel
SysExcelApplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheets sheets;
SysExcelWorksheet sheet;
SysExcelCells cells;
SysExcelCell cell;
SysExcelRange columns;
while select myTable
{
cell = sheet.cells().item(row, col);
cell.value(myTable.FieldI);
sheet.columns().autoFit();
col++;
cell = sheet.cells().item(row, col);
cell.value(myTable.FieldII);
sheet.columns().autoFit();
col++;
row++;
col=1;
}
// when the cycle end save my file
但有时我会给出类似消息调试的错误
"变量赋值中的参数类型错误"
或
"提供的参数数量与方法接受的参数数量不同"
但奇怪的是,如果我再次尝试重新启动导出,我将不会收到错误。
我有这个问题
我有相同的代码和相同的数据。
当我生成文件时,excle 行是完美的。
我在 50% 的案例中遇到了这个问题。
创建的行少了1700。
它取决于什么?我有很多行?还是其他?
我分享了在网上发现的相同问题 Some question ,我尝试使用,但没有解决我的问题:
我添加了更多信息,但没有解决我的问题 change settings
谢谢指教,
享受
是的,在开发任何导出时 Excel 有这个问题,当很多行时。如果行数很少,它就完美了。
对于这种情况,始终将 excel 导出更改为 CSV 导出。导出 csv 文件的代码永远不会失败并且工作完美!
这里我举一个导出5行csv文件的例子
代码:
static void ExportCSV(Args _args)
{
Commaio file;
container lineCSV;
#File
str DatosLinea[500];
int _i;
str filename;
Dialog dialog;
DialogField dialogFileName;
;
dialog = new Dialog("Path CSV");
dialogFileName = dialog.addField(ExtendedTypeStr("FilenameSave"),"Path File:");
if (dialog.run())
{
filename = dialogFileName.value();
}
if (!filename)
{
return;
}
file = new Commaio((filename), 'W'); //Path + file name.csv
file.outFieldDelimiter(';');
if( !file || file.status() != IO_Status::Ok)
{
throw error("File Cannot be opened");
}
DatosLinea[1] = "Col 1";
DatosLinea[2] = "Col 2";
DatosLinea[3] = "Col 3";
DatosLinea[4] = "Col 4";
DatosLinea[5] = "Col 5";
_i = 1;
lineCSV = conNull();
while(_i <= 5){
lineCSV += DatosLinea[_i];
_i += 1;
}
file.write(lineCSV);
info("Export end");
}
我有问题,我正在导入循环 Table 到 Excel。
我的代码是这样的:
#WINAPI
#Excel
SysExcelApplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheets sheets;
SysExcelWorksheet sheet;
SysExcelCells cells;
SysExcelCell cell;
SysExcelRange columns;
while select myTable
{
cell = sheet.cells().item(row, col);
cell.value(myTable.FieldI);
sheet.columns().autoFit();
col++;
cell = sheet.cells().item(row, col);
cell.value(myTable.FieldII);
sheet.columns().autoFit();
col++;
row++;
col=1;
}
// when the cycle end save my file
但有时我会给出类似消息调试的错误
"变量赋值中的参数类型错误"
或
"提供的参数数量与方法接受的参数数量不同"
但奇怪的是,如果我再次尝试重新启动导出,我将不会收到错误。 我有这个问题
我有相同的代码和相同的数据。 当我生成文件时,excle 行是完美的。 我在 50% 的案例中遇到了这个问题。
创建的行少了1700。 它取决于什么?我有很多行?还是其他?
我分享了在网上发现的相同问题 Some question ,我尝试使用,但没有解决我的问题: 我添加了更多信息,但没有解决我的问题 change settings
谢谢指教,
享受
是的,在开发任何导出时 Excel 有这个问题,当很多行时。如果行数很少,它就完美了。
对于这种情况,始终将 excel 导出更改为 CSV 导出。导出 csv 文件的代码永远不会失败并且工作完美!
这里我举一个导出5行csv文件的例子
代码:
static void ExportCSV(Args _args)
{
Commaio file;
container lineCSV;
#File
str DatosLinea[500];
int _i;
str filename;
Dialog dialog;
DialogField dialogFileName;
;
dialog = new Dialog("Path CSV");
dialogFileName = dialog.addField(ExtendedTypeStr("FilenameSave"),"Path File:");
if (dialog.run())
{
filename = dialogFileName.value();
}
if (!filename)
{
return;
}
file = new Commaio((filename), 'W'); //Path + file name.csv
file.outFieldDelimiter(';');
if( !file || file.status() != IO_Status::Ok)
{
throw error("File Cannot be opened");
}
DatosLinea[1] = "Col 1";
DatosLinea[2] = "Col 2";
DatosLinea[3] = "Col 3";
DatosLinea[4] = "Col 4";
DatosLinea[5] = "Col 5";
_i = 1;
lineCSV = conNull();
while(_i <= 5){
lineCSV += DatosLinea[_i];
_i += 1;
}
file.write(lineCSV);
info("Export end");
}