Hi Expert, i have query, i want to load data from excel to a form name ledgerjournalTransVendPaym, basically we have excel file and we want to import that file into system and the system auto fills entries in payment journal, i.e when we click on new payment journal and go to details then there should be a button through which system automatically fill following Fields of same form.
Date | Account | Credit | Txt |
---|---|---|---|
02/12/2018 | C-xxxx | 58787 | Cust Credit |
02/12/2018 | C-yyy | 5454 | det |
02/12/2018 | C-zzzz | 5454 | test debit |
i have following code, its work fine for date and Txt but for the credit and Account it does not work,
void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
COMVariant value;
Name name;
FileName filename;
TOI_ImportExcelForLegerJournalTrans esh_sampletable; //Declaring Table Name
int row=1;
int64 Dm,_DebitCredit;
real AmountdebitCur;
DimensionDynamicAccount Dim;
date _Date ;
str _Date1,_debitCredit1,_demnsions1,_Descriptions,instNum;
TOI_ImportExcelForLegerJournalTrans TOI_ImportExcelForLegerJournalTrans;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//delete_from TOI_ImportExcelForLegerJournalTrans;
//specify the file path that you want to read
filename ='C:\\Insert\\Testing127.xlsx'; //ExcelSheet File Name
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened');
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
_Date1 = cells.item(row, 1).value().toString();
_Date=str2Date(_Date1,123);
_demnsions1=cells.item(row,2).value().bStr();
Dim=str2int64(_demnsions1);
// info(_debitCredit1);
_Descriptions=cells.item(row,4).value().bStr();
instNum=cells.item(row,5).value().bStr();
//info(_Descriptions);
//TOI_ImportExcelForLegerJournalTrans.TransDate=_Date;
ledgerjournalTrans.TransDate=_Date;
LedgerJournalTrans.ledgerdimension=Dim;
ledgerjournalTrans.txt=_Descriptions;
ledgerjournalTrans.InstNumber=instNum;
ledgerjournalTrans.AmountCurCredit=AmountdebitCur;
//TOI_ImportExcelForLegerJournalTrans.Amount=_DebitCredit;
ledgerjournalTrans.insert();
//TOI_ImportExcelForLegerJournalTrans.insert();
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
super();
ledgerjournalTrans_ds.refresh();
ledgerjournalTrans_ds.research();
}
plz guide where i am making mistake.
Thanks and Regards.