Download excel template

Hi ,

I want to download a excel template with some header fields only(eg.- Name, Designation, Department etc). But it should be happen after clicking the button, which I have created in Dialog Form/Box. How can i do it.

Please help me.

Thanks in Advance,

Mani.

could u plz provide any screen shots. what do u want . and always tag ur version

do one thing write a customized class and attach class menuitem to button.

static void TheaxaptaCreateExcel(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
//Filename
fileName = “C:\Test.xlsx”;
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value(“Department”);
xlsWorkSheet.cells().item(row,2).value(“Name”);

xlsWorkSheet.cells().item(row,2).value(“Designation”);
row++;
//Fill Excel with CustTable AccountNum and Name fields (only 20 records)

//Check whether the document already exists
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//Save Excel document
xlsWorkbook.saveAs(fileName);
//Open Excel document
xlsApplication.visible(true);
//Close Excel
//xlsApplication.quit();
//xlsApplication.finalize();
}

Hi Sree,

Thanks for reply, “AX 2012 r3”:After clicking button, that I have created in Dialog box, Should be download this type excel,this is my requirement. Below is

My screenshot.

Thanks

Mani

use below code and write code in class and attach calss menu item to button . then u will get above format.