Special characters in Excel spreadsheet generated in Delphi

3

I found on the internet many codes related to generating EXCEL worksheets in DELPHI. Here is 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 such as:

Sheet.Range['B4'] := 'M A T É R I A S   -   P R I M A S';  

In EXCEL, you change special characters, for example:

M A T Ã R I A S   -   P R I M A S   

Outside the lookup fields, like:

Sheet.Cells[l,2]:=dmOrcamentos.ztBaseOrcamento.FieldByName('MP_DESC').Text;

The data looks like this:

䡃㠠〬‰䅓⁅〱㠰

How can I format characters to stay as they should?

    
asked by anonymous 03.08.2015 / 15:09

2 answers

0

I used the Lazarus FPSpreadsheet to solve the problem. With the function:

MyWorksheet.WriteUTF8Text(linha, coluna, 'M A T É R I A S - P R I M A S'); 

Follow the Wiki link for more information: FPSpreadsheet Wiki

    
02.09.2015 / 14:32
0

Try the following < Sheet.Range['B4'] := WideString('M A T É R I A S - P R I M A S');

    
03.08.2015 / 19:50