SAP逐行寫出Excel檔案
report ztest_export_excel.
include ole2incl.
data: application type ole2_object,
workbook type ole2_object,
sheet type ole2_object,
cells type ole2_object.
constants: row_max type i value 256.
data index type i.
data: begin of itab occurs 0,
first_name(10),
last_name(10),
address(100),
end of itab.
start-of-selection.
...
[@more@]"Add data to itab
itab-first_name = '123445'.
itab-last_name = 'tesst'.
itab-address = '中國'.
append itab.
clear itab.
itab-first_name = 'ABCDE'.
itab-last_name = 'tessasdfasdft'.
itab-address = '中國中山'.
append itab.
clear itab1.
itab-first_name = '123456'.
itab-last_name = 'tessasdfasdft'.
itab-address = '中國中山'.
append itab.
clear itab.
create object application 'excel.application'.
set property of application 'visible' = 1.
call method of application 'Workbooks' = workbook.
call method of workbook 'Add'.
call method of application 'Worksheets' = sheet
exporting #1 = 1.
call method of sheet 'Activate'.
set property of sheet 'Name' = 'Sheet1'.
"寫標題
index = 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = 'Field1'.
index = index + 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = 'Field2'.
index = index + 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = 'Field3'.
"寫資料
loop at itab.
index = row_max * sy-tabix + 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = itab-first_name.
index = index + 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = itab-last_name.
index = index + 1. " 1 - column name
call method of sheet 'Cells' = cells exporting #1 = index.
set property of cells 'Value' = itab-address.
endloop.
* 儲存檔案
call method of sheet 'SaveAs'
exporting #1 = 'c:tempexceldoc1.xls' "filename
#2 = 1. "fileFormat
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-915245/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP UI5 表格資料如何匯出成 Excel 檔案(Table Export As Excel)UIExcelExport
- Python批次分割Excel後逐行做差、合併檔案的方法PythonExcel
- 在web上逐行輸出較大的txt檔案Web
- python讀寫excel檔案PythonExcel
- java匯出Excel檔案JavaExcel
- 用Pandas讀寫Excel檔案-輸出單sheet和多sheetExcel
- 用XML編寫EXCEL檔案,XML的寫法注意事項,可以C#+xslt匯出ExcelXMLExcelC#
- 將 SAP ABAP 內表內容本地匯出成 Excel 檔案試讀版Excel
- Linux下輸出excel檔案LinuxExcel
- POI匯出excel檔案加水印Excel
- 【淺出 PHP】PHP 檔案操作 寫檔案PHP
- Laravel-admin 匯出excel檔案LaravelExcel
- 【Mysql】匯出資料到excel檔案中MySqlExcel
- vue3 匯出為Excel檔案VueExcel
- Shell指令碼逐行處理文字檔案技巧指令碼
- Pandas 基礎 (4) - 讀 / 寫 Excel 和 CSV 檔案Excel
- Python讀寫EXCEL檔案常用方法大全PythonExcel
- python讀寫excel檔案簡單應用PythonExcel
- 金山文件怎麼匯出excel檔案 金山文件到處excel檔案的方法Excel
- 報表如何批次匯出成 excel 檔案Excel
- 使用PHP原生匯出Excel和CSV檔案PHPExcel
- matlab輸出資料為excel檔案MatlabExcel
- EasyExcel完成excel檔案的匯入匯出Excel
- C#中DataGrid匯出Excel檔案C#Excel
- 如何讓sqlplus spool輸出的檔案成excel檔案SQLExcel
- 如何在Shell指令碼中逐行讀取檔案指令碼
- VB讀取文字檔案的例子:逐行讀取
- Java 通過Xml匯出Excel檔案,Java Excel 匯出工具類,Java匯出Excel工具類JavaXMLExcel
- Json檔案轉換為Excel檔案!涉及讀檔案,時間戳轉化,寫文件JSONExcel時間戳
- 如何使用JavaScript匯入和匯出Excel檔案JavaScriptExcel
- SQL通過bcp匯出資料到excel檔案SQLExcel
- Python逐行讀取檔案常用的三種方法!Python
- 用linux shell逐行讀取文字檔案內容Linux
- Excel開啟CSV檔案出現亂碼怎麼辦?Excel開啟csv檔案出現亂碼的解決方法Excel
- 使用 SAP ABAP 封裝的 Office Integration class 訪問本地 Excel 檔案封裝Excel
- python讀取兩個excel資料檔案輸出整理好以後的excel資料檔案PythonExcel
- Laravel5.6中使用Laravel/Excel實現Excel檔案匯出功能LaravelExcel
- Python|讀、寫Excel檔案(三種模組三種方式)PythonExcel