Reputation: 1581
I have a problem, I'm importing cycling a Table to Excel.
My code is look like this :
#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
But sometimes I give an error look like message debug
"Wrong argument types in variable assignment"
or
"The number of arguments provided is different from the number of arguments accepted by the method"
But the weird thing is if i try againg to re-launch the export I will not get the errors. I have this problem
I have same code and same data. When I generate the file the excle rows are perfect. I have this problem in 50% of these cases.
The rows created are 1700 more less. What does it depend on? I have a lot rows? Or other?
I share the same question found on web Some question ,I tried to use, but did't solved my problem: I add more information not slved my problem change settings
Thanks in advice,
enjoy
Upvotes: 1
Views: 1650
Reputation: 2238
Yes, when develop any export Excel had this problem, when many rows. If there are few rows it works perfect.
For this cases always change the excel export for CSV export. The code to export csv file never fail and work perfect!
Here I leave an example to export csv file with 5 rows.
Code:
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");
}
Upvotes: 1