static void SK_insertdatathroughExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
Sk_Exceltable sk_Exceltable;
int row;
str Name1;
str Address;
FileIoPermission perm;
#define.FileMode('W')
;
//specify the file path that you want to read
filename = "C:\\Users\\shivakumar.p\\Desktop\\Excel.xlsx";
perm = new FileIOPermission(filename, #FileMode);
perm.assert();
application = SysExcelApplication::construct();
workbooks = application.workbooks();
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
//progress.setAnimation(#AviTransfer);
try
{
ttsbegin;
do
{
row++;
if (row >= 1)
{
//Name1 = any2int(cells.item(row, 1).value().toString());
Name1 = cells.item(row, 1).value().bStr();
Address = cells.item(row, 2).value().bStr();
sk_Exceltable.Name = Name1;
sk_Exceltable.Address = Address;
sk_Exceltable.insert();
type = cells.item(row+1, 1).value().variantType();
}
}
while (type != COMVariantType::VT_EMPTY);
ttscommit;
}
catch(Exception::Error)
{
workbooks.close();
CodeAccessPermission::revertAssert();
application.quit();
ttsabort;
}
workbooks.close();
CodeAccessPermission::revertAssert();
application.quit();
}
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
Sk_Exceltable sk_Exceltable;
int row;
str Name1;
str Address;
FileIoPermission perm;
#define.FileMode('W')
;
//specify the file path that you want to read
filename = "C:\\Users\\shivakumar.p\\Desktop\\Excel.xlsx";
perm = new FileIOPermission(filename, #FileMode);
perm.assert();
application = SysExcelApplication::construct();
workbooks = application.workbooks();
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
//progress.setAnimation(#AviTransfer);
try
{
ttsbegin;
do
{
row++;
if (row >= 1)
{
//Name1 = any2int(cells.item(row, 1).value().toString());
Name1 = cells.item(row, 1).value().bStr();
Address = cells.item(row, 2).value().bStr();
sk_Exceltable.Name = Name1;
sk_Exceltable.Address = Address;
sk_Exceltable.insert();
type = cells.item(row+1, 1).value().variantType();
}
}
while (type != COMVariantType::VT_EMPTY);
ttscommit;
}
catch(Exception::Error)
{
workbooks.close();
CodeAccessPermission::revertAssert();
application.quit();
ttsabort;
}
workbooks.close();
CodeAccessPermission::revertAssert();
application.quit();
}
No comments:
Post a Comment