today we will see how to export template like if you have written any uploaded but after some time you don't remember which value will come first or you forget the sequence.
For this situation we will make the template you just need to fill the template and then import the data in ax 2012.
class BEUploadTickets extends RunBaseBatch
{
DialogRunbase dialog;
DialogField fileNameField;
FilenameOpen csvFileName;
}
protected Object dialog()
{
container conFilter;
DialogText dlgText;
DialogGroup exportGroup, importGroup;
FormBuildControl dialogGroupControlExp, dialogGroupControlImp;
FormBuildButtonControl exportTemplateButton;
;
#File
dialog = super();
conFilter = ['Excel File","*.xlsx'];
importGroup = dialog.addGroup('Import');
dialogGroupControlImp = dialog.formBuildDesign().control(importGroup.formBuildGroup().id());
fileNameField = dialog.addField(extendedTypeStr('FilenameOpen'));
dialog.filenameLookupFilter(conFilter);
dlgText = dialog.addText('\nPlease Select a EXCEL file to upload Ticket info data.');
dlgText.displayHeight(3);
exportGroup = dialog.addGroup('Export');
dialogGroupControlExp = dialog.formBuildDesign().control(exportGroup.formBuildGroup().id());
exportTemplateButton = dialogGroupControlExp.addControl(FormControlType::Button,'exportTemplateButton');
exportTemplateButton.text("@SYS91539");
exportTemplateButton.backgroundColor(10);
exportTemplateButton.backStyle(5);
exportTemplateButton.bold(15);
exportTemplateButton.foregroundColor(7);
return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
super(dialog);
_dialog.formRun().controlMethodOverload(true);
_dialog.formRun().controlMethodOverloadObject(this);
}
protected void exportTemplate()
{
#AviFiles
SysOperationProgress progress1 = new SysOperationProgress();
SysExcelApplication sysExcelApplication;
SysExcelWorkbooks sysExcelWorkBooks;
// FileName fileName = @'C:\\Desktop\\Mounting\\Mounting Journal.xlsx';
SysExcelWorkbook sysExcelWorkBook;
SysExcelWorkSheets sysExcelWorkSheets;
SysExcelWorkSheet sysExcelWorkSheet;
SysExcelWorksheet sysExcelWorkSheetToBeDeleted;
SysExcelStyles styles;
SysExcelStyle style;
SysExcelFont font;
SysExcelCells cells;
int row = 1;
boolean workSheetAdded = false;
;
progress1.setCaption('Export To Excel in progress...');
progress1.setAnimation(#AviTransfer);
sysExcelApplication = SysExcelApplication::construct();
sysExcelWorkBooks = sysExcelApplication.workbooks();
sysExcelWorkBook = sysExcelWorkBooks.add();
styles = sysExcelWorkBook.styles();
style = styles.add('Header');
font = style.font();
font.bold(true);
font.color(255);
sysExcelWorkSheets = sysExcelWorkbook.worksheets();
sysExcelApplication.visible(true);
while(sysExcelWorkSheets.count() > 1)
{
sysExcelWorkSheetToBeDeleted = sysExcelWorkSheets.itemFromNum(2);
sysExcelWorkSheetToBeDeleted.delete();
}
sysExcelWorkSheet = sysExcelWorkSheets.add(null,null,1);
sysExcelWorkSheet.name('Ticket Uploader Template');
sysExcelWorkSheet.cells().item(1,1).value('Ticket Type');
sysExcelWorksheet.cells().item(1,2).value('Ticket sub type ID');
//sysExcelWorksheet.cells().item(1,3).value('');
sysExcelWorksheet.cells().item(1,4).value('Contract Id');
sysExcelWorksheet.cells().item(1,5).value('Property Id');
sysExcelWorksheet.cells().item(1,6).value('Move In Customer');
sysExcelWorksheet.cells().item(1,7).value('Disconnection Date');
sysExcelWorksheet.cells().item(1,8).value('DL Charge Date');
sysExcelWorksheet.cells().item(1,9).value('Settlement Date');
sysExcelWorksheet.rows().item(1).style('Header');
{
progress1.setText(strfmt("@BEL958"));
sysExcelWorksheet.columns().autoFit();
cells = sysExcelWorksheet.cells();
cells.range('D2:D99').numberFormat('0,00');
workSheetAdded = false;
}
sysExcelWorksheet.columns().autoFit();
sysExcelApplication.displayAlerts(false);
}
public void exportTemplateButton_clicked()
{
this.exportTemplate();
}
public static void main(Args _args)
{
BEUploadTickets uploadsTicket = new BEUploadTickets();
if(uploadsTicket.prompt())
{
BEUploadTickets::uploadandValidateData();
}
}
private static void uploadandValidateData()
{
}
see the below image when you click on the Create Template button
Fill all the values in it and import the file.