Hi everyone :)
I'm trying to expand my app with some excel i/o features and i'm stuck with showing data...
When i try to execute
if OpenDialog1.Execute then
AdvGridExcelIO2.XLSImport(OpenDialog1.FileName);
value of clicked cell (AdvStringGrid1.Cells[ACol, ARow]) is
'|'#0'I'#0'N'#0'S'#0'T'#0'A'#0'L'#0'A'#0'C'#0'I'#0'J'#0'E'#0' '#0'V'#0'O'#0'D'#0'O'#0'V'#0'O'#0'D'#0'A'#0' '#0'I'#0' '#0'K'#0'A'#0'N'#0'A'#0'L'#0'I'#0'Z'#0'A'#0'C'#0'I'#0'J'#0'E'
Every character in cell is separated with #0 for some reason...
when i execute
if OpenDialog1.Execute then
AdvStringGrid1.LoadFromXLS(OpenDialog1.FileName);
on same xls file, i get regular value: "INSTALACIJE VODOVODA I KANALIZACIJE"..
can someone help me with this plz?
thanks in advance
Martin
As there is no information on the Delphi version you use,
I suspect you're using a non unicode Delphi version and you import unicode cells.
In this case, specify a unicode inplace editor, for example edUniEdit
I'm using delphi 2007 on windows xp..
only property editor i found is DefaultEditor and after i changed it to edUniEdit, i still have same results...
here's my complete code...
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, BaseGrid, AdvGrid, AdvOfficeStatusBar, AdvToolBar, Menus,
AdvMenus, AdvGlowButton, AdvGridWorkbook, tmsAdvGridExcel, StdCtrls, ComCtrls;
type
TForm2 = class(TForm)
AdvMainMenu1: TAdvMainMenu;
AdvDockPanel1: TAdvDockPanel;
AdvToolBar1: TAdvToolBar;
AdvOfficeStatusBar1: TAdvOfficeStatusBar;
AdvGlowButton1: TAdvGlowButton;
OpenDialog1: TOpenDialog;
AdvGridExcelIO2: TAdvGridExcelIO;
AdvStringGrid1: TAdvStringGrid;
RichEdit1: TRichEdit;
procedure AdvGlowButton1Click(Sender: TObject);
procedure AdvStringGrid1ClickCell(Sender: TObject; ARow, ACol: Integer);
private
// WorkBookGrid3: TAdvStringGrid;
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.AdvGlowButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
AdvGridExcelIO2.XLSImport(OpenDialog1.FileName);
end;
procedure TForm2.AdvStringGrid1ClickCell(Sender: TObject; ARow, ACol: Integer);
begin
RichEdit1.Text := AdvStringGrid1.Cells[ACol, ARow];
end;
end.
Your cells are unicode, as such, to retrieve this as a unicode string, you should
use grid.WideCells[col,row]: widestring;
You can't assign this as-is to a TRichEdit if you use a non unicode Delphi version
unless you convert the unicode string to an ANSI string,
Changed Cells[] to WideCells[] and works now... Thanks :)