Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decision Cube and Excel

Status
Not open for further replies.

Gigatech

Programmer
Jul 12, 2000
80
CR
I'm using D7 under Windows XP. I need to send all the cells of my Decision Grid result to Excel. I need to edit them from Excel. I can´t send to Excel as an image.

Thanks a lot.
 
I don't know about doing this from a DecisionGrid, but here's a technique that I use. It takes an OLEVariant type array, fills it from a query and puts the entire array in an excel spreadsheet. Perhaps you could use this instead of the Decision Grid?

Code:
var
Alist : variant;

begin

AList := VarArrayCreate([0, [COLOR=blue]datacounter - 1[/color], 0, [COLOR=red]11[/color]], varvariant);

//PaymentInfo is my query

PaymentInfo.First;

for i := 0 to datacounter - 1 do
begin
  with PaymentInfo do
  begin
  AList[i, 0] := UpperCase(FieldByName('FIRSTNAME').AsString + ' ' + FieldByName('LASTNAME').AsString);
  AList[i, 1] := UpperCase(FieldByName('STREET1').AsString);
  AList[i, 2] := UpperCase(FieldByName('STREET2').AsString);
  AList[i, 3] := UpperCase(FieldByName('CITY').AsString);
  AList[i, 4] := UpperCase(FieldByName('STATE').AsString);
  AList[i, 5] := FieldByName('ZIPCODE').AsString;
  AList[i, 6] := FieldByName('TOTALHRS').AsString;
  AList[i, 7] := FieldByName('TOTHRPAY').AsString;
  AList[i, 8] := FieldByName('TOTALMLS').AsString;
  AList[i, 9] := FieldByName('TOTMLPAY').AsString;
  AList[i, 10] := FieldByName('TOTALPAY').AsString;
  Next;
end;

excelapp:= CreateOleObject('Excel.Application');
excelapp.Visible := False;
excelapp.Workbooks.Open('R:\Case Management\JMSv2\Forms\Vouchers.xls');
excelsht :=  excelapp.WorkSheets.Item['ImportData'];
excelsht.Activate;
[b]//set excel range to size of AList array and transfer array in full[/b]
excelsht.Range[excelsht.Cells.Item[2, 1], excelsht.Cells.Item[datacounter - 1, 11]].Value := AList;
//this is the command to run an excel macro that takes the raw data from the 'ImportData' worksheet and creates the actual information I need to produce

excelapp.Run('Generate_VoucherRpt');

end;
the blue datacounter is the number of rows, the red 11 is the number of columns.


Leslie
 
Hi Leslie,

I tried your suggestion but encountered the error message:

"undeclared identifier: excelapp"

How should I declare excelapp? Thanks.
 
As a variant, sorry for the omission:

Code:
var
excelapp, excelsht : variant;

leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top