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

How can I set the Backgoundcolor of an AX2012 Action Pane Button
How to Edit address using X++ in AX 2012
Number sequence issue Ax 2012?
Find code that's running in a Batch Job
What is the _isMexican boolean for in the Global::Checkpower method?
AlwaysOnTop property not behaving properly
Boolean AND logic in Microsoft Dynamics AX 2012 AIF QueryCriteria
Table: PrintMgmtSettings Field: Printjobsettings(Blob)
What happened to the hrplimittablerelationship table in ax-2012-r2?
Why is my changes ignored to releaseupdate scripts in dynamics ax 2012 r2
What is “old sys” exactly and why would I receive errors in 2012 because of a missing Macro?
How to filter records in line grid based on selected record in header grid?
Dynamic linking gets cleared when inserting new records
Box::info showing “refreshEx”
How to filter lookup values on a dialogfield in Report Dialog based on another dialogfield in AX 2012 AOT reports?
Adding scrollbar to a Group in AX 2012 form

Categories

HOME
oracle12c
fuelux
jmeter
android-studio-2.2
rdbms
owl-carousel
pdfbox
soa
maxscript
retrofit2
google-chrome-app
ipmitool
internationalization
google-content-api
cgbitmapcontext
pchart
aggregation
mount
ckfinder
interbase
flooding
winexe
cppreference
userdefaults
event-flow
scatter3d
angularjs-material
hibernate-validator
git-squash
rselenium
android-sugarorm
dsx-desktop
getpixel
yowsup
parse-tree
watchman
bc
linq-to-objects
clang++
pom.xml
opennms
dbcontext
bluez
podscms
java-bytecode-asm
filehandle
sundials
arules
py2neo
javafx-css
testrail
pure-css
grails-plugin
greatest-n-per-group
mongodb-php
respondcms
swizzling
embedding
omniauth-facebook
hadoop-partitioning
libav
findfirst
spring-retry
themoviedb-api
django-urls
phonertc
sony-lifelog-api
amiga
sha512
baasbox
airbrake
mmwormhole
variadic-templates
android-cookiemanager
boost-program-options
with-statement
grails-domain-class
conditionaltagsupport
sphinxql
kaleidoscope
jquery-1.9
pclzip
chart-director
pstack
monotouch.dialog
qtconcurrent
vfs
saleslogix
iboutlet
fitbounds
relative
gobject-introspection
procedures
denied
inline-formset
photolibrary
non-clustered-index
burndowncharts
dsoframer
blind

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App