yoske1
asked on
export data to excel
Hi,
I exported data from a flexgrid to an excel-sheet. Now I have another problem. The data in the flexgrid are not recognized as doubles in excel. All the data with a comma, are recognized as strings. How can I change this? So how can I make excel recognize my data with comma's as normal data.
this is the code:
Set ApExcel = CreateObject("Excel.applic ation") 'Creates an object
ApExcel.Visible = True ' So you can see Excel
ApExcel.Workbooks.Add 'Adds a new book.
For x = 1 To aantal
For y = 1 To aantal
ApExcel.selection.numberfo rmat = ""
ApExcel.Cells(x, y).Value = MSFlexGrid1.TextMatrix(x, y) 'Add Text to a Cell
'You can use the line above, changing coordenates to go to any
'cell and you can also add Formulas
Next
Next
greetz,
yoske
I exported data from a flexgrid to an excel-sheet. Now I have another problem. The data in the flexgrid are not recognized as doubles in excel. All the data with a comma, are recognized as strings. How can I change this? So how can I make excel recognize my data with comma's as normal data.
this is the code:
Set ApExcel = CreateObject("Excel.applic
ApExcel.Visible = True ' So you can see Excel
ApExcel.Workbooks.Add 'Adds a new book.
For x = 1 To aantal
For y = 1 To aantal
ApExcel.selection.numberfo
ApExcel.Cells(x, y).Value = MSFlexGrid1.TextMatrix(x, y) 'Add Text to a Cell
'You can use the line above, changing coordenates to go to any
'cell and you can also add Formulas
Next
Next
greetz,
yoske
ASKER
ok, I found it already, this is the code:
ApExcel.Cells(x, y).Value = CDbl(MSFlexGrid1.TextMatri x(x, y))
ApExcel.Cells(x, y).Value = CDbl(MSFlexGrid1.TextMatri
ASKER
tx for the effort, I tried it too, but yours doesn't work in my program supunr, sorry
mmm....it seems to be working fine for me even with out the Format function. What version of Excel do you have?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tried it, but doesnt work, but I will accept your answer for the efforts.
It seems as if a bug is in Excel. You can make this experiment:
create a txt file with three lines:
1,01 1.000
1,1 1.000,1
1000,1
now open excel and import it as tabbed separated file.
Everithing seems fine.
Now close it. Change extension of txt file to xls, and doubvleclick it.
Excel will open it, but you will see spomething strange:
some numbers (thoose with Dot in) looses decimals or they are converted to string format...
create a txt file with three lines:
1,01 1.000
1,1 1.000,1
1000,1
now open excel and import it as tabbed separated file.
Everithing seems fine.
Now close it. Change extension of txt file to xls, and doubvleclick it.
Excel will open it, but you will see spomething strange:
some numbers (thoose with Dot in) looses decimals or they are converted to string format...
ApExcel.Cells(x, y).Value = MSFlexGrid1.TextMatrix(x, y) 'Add Text to a Cell
to
ApExcel.Cells(x, y).Value = Format(MSFlexGrid1.TextMat
Good Luck!