2016-12-14 54 views
-1

我想在斧頭2012中通過X ++讀取它後更新Excel文件。我知道如何編寫,但是我想在從Excel工作表讀取後寫入?以下是編寫代碼:如何在ax2012中通過X ++讀取Excel文件後進行更新?

static void CreateExcelFile(Args _args) 
{ 
    CustTable custTable; 
    SysExcelApplication excel; 
    SysExcelWorkbooks workbooks; 
    SysExcelWorkbook workbook; 
    SysExcelWorksheets worksheets; 
    SysExcelWorksheet worksheet; 
    SysExcelCells cells; 
    SysExcelCell cell; 
    int row; 
    excel = SysExcelApplication::construct(); 
    workbooks = excel.workbooks(); 
    workbook = workbooks.add(); 
    worksheets = workbook.worksheets(); 
    worksheet = worksheets.itemFromNum(1); 
    cells = worksheet.cells(); 
    cells.range('A:A').numberFormat('@'); 
    while select custTable 
    { 
     row++; 
     cell = cells.item(row, 1); 
     cell.value(custTable.AccountNum); 
     cell = cells.item(row, 2); 
     cell.value(custTable.name()); 
    } 
    excel.visible(true); 
} 

回答

0

您是否嘗試過使用WorkBook.saveAs方法?

+0

B是的,我的要求是在閱讀內容後,我想添加一個新的列並將確認的消息寫入每行 – user1371416

相關問題