Hello everyone,
I am working in Dynamics 2012, trying to export some data in CSV format.
What I am trying to do is to export data of Field1 from TableA. Field1 is of type string, size 10. The problem is that one of the values that contains Field1 is 6549030E82 and when i open it in csv(excel) it is saved as scientific, as in the image here.
What I want is that when I open the file, to be shown as 6549030E82.
To achieve this I have tried, both the following scenarios, but both of them show the scientific value.
Scenario1.
public void exportCSV()
{
#File
commaIO commaIO;
FileIOPermission permission;
Table tableA;
container record;
permission = new FileIOPermission(fileName,'RW');
permission.assert();
commaIO = new commaIO(fileName,'W');
commaIO.outFieldDelimiter(';');
commaIO.write("@MIS95","@SYS59532","@SYS80949", 'line');
while select tableA
{
record = [tableA.Field1];
commaIO.writeExp(record);
}
CodeAccessPermission::revertAssert();
}
Scenario 2
public void exportExcel()
{
FileIOPermission fioPermission;
SysExcelApplication application;
SysExcelWorkBooks workBooks;
SysExcelWorkBook workBook;
SysExcelWorkSheet workSheet;
SysExcelCells cells;
int i;
application = SysExcelApplication::construct();
workBooks = application.workbooks();
workBook = workBooks.add();
workSheet = workBook.worksheets().itemFromNum(1);
cells = worksheet.cells();
while select TableA
{
cells.item(i,1).value(TableA.Field1);
i++;
}
workSheet .columns().autoFit();
application.displayAlerts(false);
workbook.saveAs(filename, 6);
workbook.comObject().save();
workbook.saved(true);
application.quit();
}
In the above scenario, I have even tried to format the whole excel column cell.range('A1:A100').NumberFormat(' ');, but it ignores the value 6549030E82 and shows empty cell.
Can anyone suggest something in order to show the right value, i mean to show the string value and not convert it to scientific format. . I can use any of the scenarios, it is important to show the right value.
Thanks in advance.