Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (58 sloc) 2.11 KB
// Codice fornito con licenza MIT (https://opensource.org/licenses/MIT)
static void ag_pec_import(Args _args)
{
custtable custtable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet,worksheet1;
SysExcelCells cells,cells1;
COMVariantType type,type1;
int row=0;
int inserted =0;
Accountnum accountnum;
// Finestra di dialogo
Dialog dialog;
DialogField dfFileName;
FileName fileName;
#Excel
;
dialog = new Dialog("Select file");
dialog.addText("Excel file must have no column header. Sheet must be named 'Import'.");
dfFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter(["@SYS28576",#XLSX,"@SYS28576",#XLS]);
dialog.filenameLookupTitle("Import from Excel");
if(dialog.run())
{
filename = dfFileName.value();
}
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(filename);
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromName("Import"); // Il job importa i dati dal foglio chiamato Import
cells = worksheet.cells();
do
{
row++; // incrementa la riga passando alla successiva
custtable.clear();
accountnum = cells.item(row,1).value().bStr();
custtable = custtable ::find(accountnum ,true);
if(custtable.recid > 0)
{
ttsBegin;
custtable.FIELD = cells.item(row,2).value().bStr(); //sostituire FIELD con il campo da valorizzare *****
custtable.EInvoiceRegister_IT = 1; //inserisce il flag sull'abilitazione fattura elettronica ******
custtable.update();
inserted++;
ttsCommit;
}
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
workbook.close(false); //chiudono il file Excel senza prompt per il salvataggio
application.quit();
info(strFmt("%1 records updated out of %2 Excel lines", inserted,row));
}
You can’t perform that action at this time.