AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 01.11.2012, 17:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
sashanazarov: Exporting to Excel with Microsoft.Dynamics.AX.Fim.Spreadsheets.* classes
Источник: http://sashanazarov.blogspot.com/201...xcel-with.html
==============

While looking for a way to export to Excel in batch, I investigated what they do in financial statements (LedgerBalanceSheetDimPrintExcelEngine class).

Pros:
  • It is possible to use these .NET components in batch on the server side
  • Execution is way faster than that of the SysExcel* classes
Cons:
  • It looks like it is not possible to create more columns than there are letters in the English alphabet
  • Less flexible comparing to standard SysExcel classes, so manual formatting will likely be needed in the end.
static void AnotherWayToExportToExcel(Args _args)
{
#define.ReadWritePermission('RW')
#define.FileName('c:\myFile.xlsx')
#define.ExcelColumnWidth(15)
#define.ExcelCellFontSize("Microsoft.Dynamics.AX.Fim.Spreadsheets.CellFontSize")
#define.Size9("Size9")

CustTable custTable;

Microsoft.Dynamics.AX.Fim.Spreadsheets.Spreadsheet spreadsheet;
Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties cellProperties;
Microsoft.Dynamics.AX.Fim.Spreadsheets.ColumnProperties columnProperties;

void addColumn(str _name)
{
columnProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.ColumnProperties();
columnProperties.set_Width(#ExcelColumnWidth);
spreadSheet.InstantiateColumn(columnProperties);

cellProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties();
cellProperties.set_FontSize(CLRInterop::parseClrEnum(#ExcelCellFontSize, #Size9));
cellProperties.set_Bold(true);

spreadSheet.AddStringCellToWorkbook(_name, cellProperties);
}

new FileIOPermission(#FileName, #ReadWritePermission).assert();

spreadSheet = new Microsoft.Dynamics.AX.Fim.Spreadsheets.Spreadsheet();

if (!spreadSheet.CreateSpreadsheet(#FileName))
{
throw error(strFmt("@SYS72245", #FileName));
}

addColumn("Customer name");
addColumn("Balance");

while select custTable
{
spreadSheet.MoveToNextRowInWorkbook();

cellProperties = new Microsoft.Dynamics.AX.Fim.Spreadsheets.CellProperties();
cellProperties.set_FontSize(CLRInterop::parseClrEnum(#ExcelCellFontSize, #Size9));

spreadSheet.AddStringCellToWorkbook(custTable.name(), cellProperties);
spreadSheet.AddNumberCellToWorkbook(real2double(custTable.openBalanceCur()), cellProperties);
}

spreadSheet.WriteFile();
spreadSheet.Dispose();

CodeAccessPermission::revertAssert();
}
Output:



Источник: http://sashanazarov.blogspot.com/201...xcel-with.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 11 Blog bot Dynamics CRM: Blogs 0 06.10.2012 05:27
Microsoft Dynamics CRM Team Blog: Fast, Efficient Growth for Project Management Solution - Case Studies Blog bot Dynamics CRM: Blogs 0 01.02.2012 03:18
DynamicsAxSCM: Operational Sites in Microsoft Dynamics AX 2012 Blog bot DAX Blogs 0 25.05.2011 19:11
dynamics-ax: Modeling the world, with Microsoft Dynamics AX 2012 Blog bot DAX Blogs 0 25.01.2011 09:11
dynamics-ax: Official Details about Dynamics AX '6' released, including comments from Microsofts Kees Hertogh Blog bot DAX Blogs 0 11.01.2011 05:22

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:56.