I need import excel file but it has password protect file and alright i have password but how to define password in x++
i need import file with enter password via x++
My code
pathName = strFmt('%1',PathCtrl.Text());
excel = SysExcelApplication::construct();
workbooks = excel.workbooks();
try
{
workbooks.open(@pathName);
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(3);
cells = worksheet.cells();
type = cells.item(row+1, 1).value().variantType();
record_count = this.findLastRow(worksheet);
_Progress.setTotal(record_count);
while (type != COMVariantType::VT_EMPTY)
{
row++;
info(strFmt("%1",cells.item(row,1).value().bStr()));
type = cells.item(row+1, 1).value().variantType();
_Progress.setText(strFmt("%1 : %2 / %3",cells.item(row, 2).value().bStr(),row,record_count));
_Progress.setCount(row);
_Progress.update(true);
}
excel.quit();
}
catch (Exception::Error)
{
excel.quit();
throw error("File cannot be opened");
}
You input the password(s) when you open the workbook on this line:
workbooks.open(@pathName);
Change to something like:
workbooks.open(@pathName, 0, false, 5, 'OpenDocPassword', 'WriteDocPassword');
Look at \Classes\SysExcelWorkbooks_XP\open
for the function declaration.