Skip to main content
added 40 characters in body
Source Link
The_Fox
  • 7.1k
  • 2
  • 50
  • 73

Since you cannot format comments:

I just did a little test and Excel doesn't want a regional formatted float value as string, it just want a dot as decimal separator.

procedure TForm1.Button1Click(Sender: TObject); var App: Variant; Workbook: Variant; Worksheet: Variant; DoubleValue: Double; begin App := CreateOleObject('Excel.Application'); Workbook := App.Workbooks.Add; Worksheet := Workbook.ActiveSheet; DoubleValue := 1.2; Worksheet.Range['A1'].Value := DoubleValue; //DoubleValue is a double, excel recognizes a double Worksheet.Range['A2'].Value := '1.2'; //excel recognizes a double Worksheet.Range['A3'].Value := '1,2'; //excel recognizes a string Worksheet.Range['A4'].Value := FloatToStr(1.2); //excel recognizes a string App.Visible := True; end; 

Keep in mind that I hava a comma as decimal separator.

Since you cannot format comments:

I just did a little test and Excel doesn't want a regional formatted float value as string, it just want a dot as decimal separator.

procedure TForm1.Button1Click(Sender: TObject); var App: Variant; Workbook: Variant; Worksheet: Variant; DoubleValue: Double; begin App := CreateOleObject('Excel.Application'); Workbook := App.Workbooks.Add; Worksheet := Workbook.ActiveSheet; DoubleValue := 1.2; Range['A1'].Value := DoubleValue; //DoubleValue is a double, excel recognizes a double Range['A2'].Value := '1.2'; //excel recognizes a double Range['A3'].Value := '1,2'; //excel recognizes a string Range['A4'].Value := FloatToStr(1.2); //excel recognizes a string App.Visible := True; end; 

Keep in mind that I hava a comma as decimal separator.

Since you cannot format comments:

I just did a little test and Excel doesn't want a regional formatted float value as string, it just want a dot as decimal separator.

procedure TForm1.Button1Click(Sender: TObject); var App: Variant; Workbook: Variant; Worksheet: Variant; DoubleValue: Double; begin App := CreateOleObject('Excel.Application'); Workbook := App.Workbooks.Add; Worksheet := Workbook.ActiveSheet; DoubleValue := 1.2; Worksheet.Range['A1'].Value := DoubleValue; //DoubleValue is a double, excel recognizes a double Worksheet.Range['A2'].Value := '1.2'; //excel recognizes a double Worksheet.Range['A3'].Value := '1,2'; //excel recognizes a string Worksheet.Range['A4'].Value := FloatToStr(1.2); //excel recognizes a string App.Visible := True; end; 

Keep in mind that I hava a comma as decimal separator.

Source Link
The_Fox
  • 7.1k
  • 2
  • 50
  • 73

Since you cannot format comments:

I just did a little test and Excel doesn't want a regional formatted float value as string, it just want a dot as decimal separator.

procedure TForm1.Button1Click(Sender: TObject); var App: Variant; Workbook: Variant; Worksheet: Variant; DoubleValue: Double; begin App := CreateOleObject('Excel.Application'); Workbook := App.Workbooks.Add; Worksheet := Workbook.ActiveSheet; DoubleValue := 1.2; Range['A1'].Value := DoubleValue; //DoubleValue is a double, excel recognizes a double Range['A2'].Value := '1.2'; //excel recognizes a double Range['A3'].Value := '1,2'; //excel recognizes a string Range['A4'].Value := FloatToStr(1.2); //excel recognizes a string App.Visible := True; end; 

Keep in mind that I hava a comma as decimal separator.