sry faisal i can’t send full progrAM
Lev_CompanyDetails Table,tabletmp;
filenameopen fopen;
dialog dia;
dialogfield diafield;
int row,i;
#excel
#avifiles
str COMVariant2Str(COMVariant _cv, int _decimals = 0, int _characters = 0, int _separator1 = 0, int _separator2 = 0)
{
switch (_cv.variantType())
{
case (COMVariantType::VT_BSTR):
return _cv.bStr();
case (COMVariantType::VT_R4):
return num2str(_cv.float(),_characters,_decimals,_separator1,_separator2);
case (COMVariantType::VT_R8):
return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);
case (COMVariantType::VT_DECIMAL):
return num2str(_cv.decimal(),_characters,_decimals,_separator1,_separator2);
case (COMVariantType::VT_DATE):
return date2str(_cv.date(),123,2,1,2,1,4);
case (COMVariantType::VT_EMPTY):
return “”;
default:
throw error(strfmt("@SYS26908", _cv.variantType()));
}
return “”;
} ;
tabletmp.setTmp();
dia=new dialog(“Select the File”);
diafield=dia.addField(typeid(filenameopen));
if(dia.run())
{
fopen=diafield.value();
info(strfmt(“Select File is :%1”,fopen));
application=sysexcelapplication::construct();
workbooks=application.workbooks();
workbooks.open(fopen);
info(“Your File Successfully Opened…”);
workbook=workbooks.item(1);
worksheets=workbook.worksheets();
worksheet=worksheets.itemFromNum(1);
cells=worksheet.cells();
totrange=cells.range(#ExcelDatarange);
range = totrange.find("*", null, #xlFormulas, #xlWhole,#xlByRows,#xlPrevious);
info(strfmt(“Number Rows to be copied is: %1”,range.row()));
row=range.row();
for(i=2;i<=row;i++)
{
tabletmp.Company_id= str2int(COMVariant2Str(cells.item(i,1).value()));
tabletmp.Company_Name=comvariant2str(cells.item(i,2).value());
tabletmp.insert();
info(strfmt("%1 row inserted",i));
}
insert_recordset table (Company_id,Company_Name) select Company_id,Company_Name from tabletmp;
info(“Process Completed”);
application.workbooks().close();
application.quit();
}