掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
DELPHIで作成したソフトの計算結果を、エクセルで選択したセルに貼り付けたいのですが? (ID:22848)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ちょっと動作確認はできないんだけど 過去にメモしたStringGridの内容を Excelに転送するコードです。 選択したセルの指定方法が ちょっとわかんない。 良ければ 誰か、サポートしてあげてプリーズ。 procedure TForm1.OutputExcelActExecute(Sender: TObject); var Excel : Variant; WorkBook : Variant; WorkSheet : Variant; CreateNewBookFlag: Boolean; i, j: Integer; X, Y: Integer; begin try try Excel:=GetActiveOleObject('Excel.Application'); except on EOleSysError do begin Excel := CreateOleObject('Excel.Application'); end; end; WorkBook := Excel.Workbooks.Add; WorkSheet := WorkBook.WorkSheets[ 1 ]; CreateNewBookFlag := True; Excel.Visible:=True; X := 0; Y := 0; for i := 0 to StringGrid1.RowCount-1 do begin for j := 1 to StringGrid1.ColCount-1 do begin WorkSheet.Cells[X + i + 1, Y + j] := StringGrid1.Cells[j, i]; end; end; if CreateNewBookFlag then WorkSheet.Columns.AutoFit; except Excel.DisplayAlerts := False; WorkBook.close; WorkBook:=unAssigned; WorkSheet:=unAssigned; Excel.Quit; Excel:=unAssigned; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.