我必须使用 X++ 代码从 Excel 文件中读取。Bellow 是作为大型 excel 文件的一部分的一些内容。我只需要根据第一列单元格中的公共部门过滤列表 *_BillingCode、*_PSN、AccDistRuleAdvLedgerEntryExt 等。
Public Sector SL1 *_BillingCode
Public Sector SL1 *_PSN
Public Sector SL1 AccDistRuleAdvLedgerEntryExt (Class)
Public Sector SL1 AccJourRuleAdvLedgerEntryExt
Public Sector SL1 AccountantActivities
Public Sector SL1 AccountingManagerActivities
Public Sector SL1 AdvancedLedgerEntry (Class)
Public Sector SL1 AdvLedgerEntry (Prefix)
Public Sector SL1 AxAdvancedLedgerEntry (Prefix)
Public Sector SL1 AxdAdvancedLedgerEntry
Public Sector SL1 AxdCustomerTransaction (Class)
Public Sector SL1 BudgetAccountDetail (Prefix)
我在谷歌上搜索我发现以下代码行可以从 excel 文件中读取。
static void ReadFromExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
CustAccount account;
CustName name;
#define.Filename('C:\\X++ Ownership.xls')
;
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();
do
{
row++;
account = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
info(strfmt('%1 - %2', account, name));
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
}
了解如何使用上述代码以满足我的要求需要时间。我会感谢你的帮助。