AXForum  
Вернуться   AXForum > Блоги > AnGor
NAV
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

Оценить эту запись

Using EPPlus in AX 2012 as an Excel writer

Запись от AnGor размещена 04.04.2018 в 18:04

EPPlus is extremely fast! I will never work again with COM if I want to make deal with Excel!

Here you can get the newest version of EPPlus: https://github.com/JanKallman/EPPlus

As usual before work with new dll you should add it to the References.

X++:
static void GOA_EPPlus(Args _args)
{
    System.IO.FileInfo      newFileInfo;
    System.IO.FileInfo      tmpFileInfo;
    Filename    newFileName = WinAPI::getTempPath() +  "GOA_InvoiceProposalAnalysis.xlsm";
    Filename    tmpFileName = TemplateProvider_RU::getFor(_args).get(resourceStr(GOA_InvoiceProposalAnalysis));

    OfficeOpenXml.ExcelPackage ExcelPkg;
    OfficeOpenXml.ExcelWorkbook ExcelWorkbook;
    OfficeOpenXml.ExcelWorksheets ExcelWorksheets;
    OfficeOpenXml.ExcelWorksheet ExcelWorksheet;
    OfficeOpenXml.ExcelRange    ExcelRange;
    OfficeOpenXml.ExcelRange    Cell;

    Bookmark            bookmark;
    int i;
    int row = 2;

    GOA_ViewInvoiceProposal    viewInvoiceProposal ;

    newFileInfo = new System.IO.FileInfo(newFileName);
    tmpFileInfo = new System.IO.FileInfo(tmpFileName);

    ExcelPkg = new OfficeOpenXml.ExcelPackage(newFileInfo, tmpFileInfo);

    ExcelWorkbook = ExcelPkg.get_Workbook();
    ExcelWorksheets = ExcelWorkbook.get_Worksheets();
    ExcelWorksheet = ExcelWorksheets.get_Item("Data");
    ExcelRange = ExcelWorksheet.get_Cells();

    while select viewInvoiceProposal
    {
        i = 1;

        bookmark = ComExcelDocument_RU::numToNameCell(i,row);
        Cell = ExcelRange.get_Item(bookmark);
        Cell.set_Value(viewInvoiceProposal.TypeView);
        i++;
        bookmark = ComExcelDocument_RU::numToNameCell(i,row);
        Cell = ExcelRange.get_Item(bookmark);
        Cell.set_Value(viewInvoiceProposal.TypeView);
        i++;
        bookmark = ComExcelDocument_RU::numToNameCell(i,row);
        Cell = ExcelRange.get_Item(bookmark);
        Cell.set_Value(viewInvoiceProposal.CustAccount);

        row++;
    }
    ExcelPkg.Save();
}
Размещено в Без категории
Просмотров 374 Комментарии 0
Всего комментариев 0

Комментарии

 


Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:04.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.