quote: ---------- Originally posted by rafa_marius Hello! //Example for a cell type number with 2 decimals (warning!, decimal point is comma in Spain): xlsSheet.Range(‘A1’).NumberFormat := ‘########0.00’; Regards, Rafa ---------- When i try this one: xlsWorksheet Automation ‘Microsoft Excel 9.0 Object Library’.Worksheet xlsRange Automation ‘Microsoft Excel 9.0 Object Library’.Range xlsRange.Item(lineCounter, 15, FORMAT(CurrencyAmount)); xlsWorksheet.Range(lineCounter, 15).NumberFormat := ‘########0,00’; I get an error who says there was not give an exception [xx(] Anybody know what this error is caused by? And can i use (lineCounter, 15) rather then (‘A1’) and so on? Regards Frode Dahl aimit as
I just posted an answer in the Tips&Tricks forum [;)]
I used the tip from xorph and got the format to work: Dummy := ‘# ##0,00_);(# ##0,00)’; xlsRange1 := xlsWorksheet.Cells.Columns.Item(columnCounter); xlsRange2 := xlsRange1.Rows.Item(lineCounter); xlsRange2.NumberFormat(Dummy); xlsRange.Item(lineCounter, 15, FORMAT(CurrencyAmount,0,’<Decimals,2>’)); But the amounti tried to format was this: 12 000 93 790,9998782121541 35 466,0029680930002 181 221,9970703125 But now the resault come out like this: 12 000,00 93790** 35466** 181221** Anybody know why the ** is there? When i remove the ** manualy in the excel sheet i get out the right amount. /me is confused now [V] Regards Frode Dahl aimit as
Hi Frode, try this: Dummy := ‘# ##0,00_;(# ##0,00)’ Maybe the close- bracket in your code is wrong. Another hint (posted from Heinz Herbeck yesterday):
quote:
// Watch out for German Excel-Version // ‘Rot’ instead of ‘Red’, Comma instead of Point Dummy := '#.##0,00_ ;[Rot]-#.##0,00 ';
Do you have a german excel- version? Maybe you should remove the comma. Andre
Hehe… all i had to do was to remove the ,2 Wrong: xlsRange.Item(lineCounter, 15, FORMAT(CurrencyAmount,0,’<Decimals,2>’)); Correct: xlsRange.Item(lineCounter, 15, FORMAT(CurrencyAmount,0,’’)); Thnx all