Question:
I found many codes on the internet related to generating EXCEL spreadsheets in DELPHI. Here's the code I'm using:
objExcel := CreateOleObject('Excel.Application');
objExcel.Visible := True;
objExcel.Workbooks.Add;
objExcel.Workbooks[1].Sheets.Add;
objExcel.Workbooks[1].WorkSheets[1].Name := 'Orçamento';
Sheet := objExcel.Workbooks[1].WorkSheets[1];
This part works, but when I add some information, like:
Sheet.Range['B4'] := 'M A T É R I A S - P R I M A S';
In EXCEL it changes the special characters, for example, to:
M A T Ã R I A S - P R I M A S
Apart from lookup fields, such as:
Sheet.Cells[l,2]:=dmOrcamentos.ztBaseOrcamento.FieldByName('MP_DESC').Text;
that the data looks like this:
䡃㠠〬‰䅓⁅〱㠰
How can I format the characters to look like they should?
Answer:
try the following
Sheet.Range['B4'] := WideString('MAT É RIAS - PRIMA S');