I need to load in txlsspreadsheet what i put in a xlsreadwrite4 object. Is it possible?
TY, Max
Assign or load xlsreadwrite4 in txlsspreadsheet
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Hello
Yes. Write to a memory stream, and then load the stream into XLSSpreadSheet.
Yes. Write to a memory stream, and then load the stream into XLSSpreadSheet.
Lars Arvidsson, Axolot Data
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
I try:
procedure TFAnteprima.FormShow(Sender: TObject);
var Ws : TMemoryStream ; // Resource Stream write to memory stream
//s : String;
begin
xls.BeginUpdate;
ModificaReportContabile(xls,RC); //load in XLS: TXLSReadWriteII4;
//Salvo il file in stream
xls.EndUpdate;
try
Ws := TMemoryStream .Create;
Xls.WriteToStream(ws);
XLSRW.Xls.LoadFromStream(ws); //XLSRW: TXLSSpreadSheet;
ws.Free ;
except
Application.MessageBox('Errore nella creazione del report contabile', 'ATTENZIONE ',MB_OK );
end;
end;
but don't work.......
Can u help me?
Stefano
procedure TFAnteprima.FormShow(Sender: TObject);
var Ws : TMemoryStream ; // Resource Stream write to memory stream
//s : String;
begin
xls.BeginUpdate;
ModificaReportContabile(xls,RC); //load in XLS: TXLSReadWriteII4;
//Salvo il file in stream
xls.EndUpdate;
try
Ws := TMemoryStream .Create;
Xls.WriteToStream(ws);
XLSRW.Xls.LoadFromStream(ws); //XLSRW: TXLSSpreadSheet;
ws.Free ;
except
Application.MessageBox('Errore nella creazione del report contabile', 'ATTENZIONE ',MB_OK );
end;
end;
but don't work.......
Can u help me?
Stefano
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Hello
When reading from a stream, you must call InvalidateSheet after you have loaded the stream. Example:
XLSBook.InvalidateSheet(0);
When reading from a stream, you must call InvalidateSheet after you have loaded the stream. Example:
XLSBook.InvalidateSheet(0);
Lars Arvidsson, Axolot Data
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Dear Larsa,
now i try:
I try:
procedure TFAnteprima.FormShow(Sender: TObject);
var Ws : TMemoryStream ; // Resource Stream write to memory stream
//s : String;
begin
xls.BeginUpdate;
ModificaReportContabile(xls,RC); //load in XLS: TXLSReadWriteII4;
//Salvo il file in stream
xls.EndUpdate;
try
Ws := TMemoryStream .Create;
Xls.WriteToStream(ws);
XLSRW.InvalidateSheet(0); //======> your suggest
XLSRW.InvalidateSheet(1); //======> i have 2 sheets
XLSRW.Xls.LoadFromStream(ws); //XLSRW: TXLSSpreadSheet;
ws.Free ;
except
Application.MessageBox('Errore nella creazione del report contabile', 'ATTENZIONE ',MB_OK );
end;
end;
but don't work.......always the same error on line XLSRW.Xls.LoadFromStream(ws):
'stream read error'
pls can u send me a complete example?
Ty max
Can u help me?
Stefano
now i try:
I try:
procedure TFAnteprima.FormShow(Sender: TObject);
var Ws : TMemoryStream ; // Resource Stream write to memory stream
//s : String;
begin
xls.BeginUpdate;
ModificaReportContabile(xls,RC); //load in XLS: TXLSReadWriteII4;
//Salvo il file in stream
xls.EndUpdate;
try
Ws := TMemoryStream .Create;
Xls.WriteToStream(ws);
XLSRW.InvalidateSheet(0); //======> your suggest
XLSRW.InvalidateSheet(1); //======> i have 2 sheets
XLSRW.Xls.LoadFromStream(ws); //XLSRW: TXLSSpreadSheet;
ws.Free ;
except
Application.MessageBox('Errore nella creazione del report contabile', 'ATTENZIONE ',MB_OK );
end;
end;
but don't work.......always the same error on line XLSRW.Xls.LoadFromStream(ws):
'stream read error'
pls can u send me a complete example?
Ty max
Can u help me?
Stefano
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Hello
You have set the stream position to the beginning of the stream.
Example:
var
Stream: TMemoryStream;
XLS: TXLSReadWriteII4;
begin
XLS := TXLSReadWriteII4.Create(Nil);
try
Stream := TMemoryStream.Create;
try
XLS.Filename := 'd:\xtemp\t1.xls';
XLS.Read;
XLS.WriteToStream(Stream);
Stream.Seek(0,soFromBeginning);
XLSBook.XLS.LoadFromStream(Stream);
XLSBook.InvalidateSheet(0);
finally
Stream.Free;
end;
finally
XLS.Free;
end;
You have set the stream position to the beginning of the stream.
Example:
var
Stream: TMemoryStream;
XLS: TXLSReadWriteII4;
begin
XLS := TXLSReadWriteII4.Create(Nil);
try
Stream := TMemoryStream.Create;
try
XLS.Filename := 'd:\xtemp\t1.xls';
XLS.Read;
XLS.WriteToStream(Stream);
Stream.Seek(0,soFromBeginning);
XLSBook.XLS.LoadFromStream(Stream);
XLSBook.InvalidateSheet(0);
finally
Stream.Free;
end;
finally
XLS.Free;
end;
Lars Arvidsson, Axolot Data
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Ok now works perfectly!!!
From txlsspreadsheet is possible create a selection and copy of cells?
Tx Max
From txlsspreadsheet is possible create a selection and copy of cells?
Tx Max
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Hello
Yes, you can use the XSS.XLS.CopyCells method
Yes, you can use the XSS.XLS.CopyCells method
Lars Arvidsson, Axolot Data
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Ok but if i have to copy the selected cell to clipboard?
Ty
Ty
Re: Assign or load xlsreadwrite4 in txlsspreadsheet
Dear Larsa,
i find this solution:
procedure TForm.CopyClick(Sender: TObject);
var c1,c2,r1,r2, c, r : integer;
GridInfo: TStringGrid;
begin
c1 := XLSRW.XLSSheet.SelectedAreas.Items[0].Col1;
c2 := XLSRW.XLSSheet.SelectedAreas.Items[0].Col2;
r1 := XLSRW.XLSSheet.SelectedAreas.Items[0].Row1;
r2 := XLSRW.XLSSheet.SelectedAreas.Items[0].Row2;
GridInfo := TAdvStringGrid.Create(Self);
try
GridInfo.ColCount := c2-c1+1;
GridInfo.RowCount := r2-r1+1;
for c := 0 to GridInfo.ColCount - 1 do
for r := 0 to GridInfo.RowCount - 1 do
GridInfo.Cells[c,r] := XLSRW.XLSSheet.AsString[c1+c,r1+r];
GridInfo.CopyToClipBoard;
finally
gridInfo.Free
end;
end;
This is my best. Do u have a simpler solution?
i find this solution:
procedure TForm.CopyClick(Sender: TObject);
var c1,c2,r1,r2, c, r : integer;
GridInfo: TStringGrid;
begin
c1 := XLSRW.XLSSheet.SelectedAreas.Items[0].Col1;
c2 := XLSRW.XLSSheet.SelectedAreas.Items[0].Col2;
r1 := XLSRW.XLSSheet.SelectedAreas.Items[0].Row1;
r2 := XLSRW.XLSSheet.SelectedAreas.Items[0].Row2;
GridInfo := TAdvStringGrid.Create(Self);
try
GridInfo.ColCount := c2-c1+1;
GridInfo.RowCount := r2-r1+1;
for c := 0 to GridInfo.ColCount - 1 do
for r := 0 to GridInfo.RowCount - 1 do
GridInfo.Cells[c,r] := XLSRW.XLSSheet.AsString[c1+c,r1+r];
GridInfo.CopyToClipBoard;
finally
gridInfo.Free
end;
end;
This is my best. Do u have a simpler solution?