x++


How to read from an Excel file?


I have to read from a Excel file using X++ Code. Bellow is the some content as part of a large excel file. I would only need to filter list *_BillingCode, *_PSN, AccDistRuleAdvLedgerEntryExt etc on the basis of Public Sector in first column cells.
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)
I searched on google I found following lines of code to read from excel file.
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();
}
It is taking time to understand how could I utilize the above code, in order to meet my requirements. I would be thankful for your help.
There are better ways to read Excel files, see Axaptapedia (I am the author by the way).

Related Links

Refresh the main screen in ax dynamics 2009
How to insert into a table field with value from a display method dependent of string
x++ cannot read registry entry
How do I get the caller Form's name in the Insert() of a table in AX 2012?
How to lookup into another table using EDT AX 2012
Set a Date Value to a Date Field in AX2012
Determine if a job is running in X++ code
Dynamics AX 2012 parsing Int32 to table field integer
Cancel Sales order packing slip through x++
Transferring open account records between customers
How to make sure that a form is only opened once?
Extend system menu in Dynamics AX 2012?
How to show selected items of certain table on the different table in Dynamics AX 2012?
AllowEdit doesn't work properly in Dynamics AX
AX 2012 how to set args record datasource in X++
Clients seem to be running old (buggy) code after XPO project import

Categories

HOME
jpa
redux-form
pda
youtube-data-api-v3
yahoo-finance
jwplayer
requirements
replace
ms-access-2016
yandex
nsbundle
accessibility
p2p
plist
emoji
libc
selenium-ide
code-generation
atlassian
intershop
oledb
draft-js-plugins
corpus
apktool
fractions
8051
testcomplete
google-cast
aws-codecommit
zend-debugger
mustache
jmockit
glib
card.io
dsx-desktop
roblox
searchkit
hivemq
playframework-2.1
diacritics
trigonometry
dbnull
print-css
apollostack
podscms
context-switch
video-conferencing
appdomain
avx
reshape
janus
renaming
atlas
mapxtreme
winusb
google-cloud-console
macaulay2
cda
lz77
grass
aspen
np-spring
blitline
crouton-os
qt5.2
text-search
rrule
broadband
exceldatareader
mass-assignment
ejb-2.x
packet-sniffers
mruby
jbake
encryption-asymmetric
build-script
reflector
websphere-esb
qscrollarea
syndicationfeed
notorm
jammer
twisted.web
asplinkbutton
bjyauthorize
device-width
boost-msm
paginator
entity-attribute-value
role
workflow-services
quotation-marks
cloudfiles
cac
cruisecontrol.rb
delimited-text
hbm2java
tui
interop-domino
complex-event-processing
firefox-3
java1.4

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App