Forum Discussion
FICO
5 years agoCommunity Manager
I am trying to write to Excel from mosel. I want this write to always append to the existing content in the excel workbook. I read that the 'grow' attribute would work this way. However, does not app
I am using the following mosel code: to write to a given excel workbook output file. The output is written, but it does not append correctly. Note, the output table being written can be sparse (empty cells).
initializations to "mmsheet.xlsx:grow;" + output_file
3 Replies
- FICOCommunity Manager
Writing to an Excel spreadsheet with any of the mmsheet spreadsheet drivers does not affect the definition of ranges within the spreadsheet. Via the 'grow' option you indicate that output can continue under the row that is specified as (start of) the output range without modifying the range definition itself.
This means that any follow-up output will start at the same position as the original output (hence overwriting any existing contents) - any changes to the output location need to be implemented programmatically, either on the Mosel level (keeping track of the number of lines written, eg. via a call to 'getsize' for the entity that is written and calculating the next output location correspondingly: the row-column notation for explicit range definitions lends itself best for this purpose) or within the Excel spreadsheet using some VBA code (in this case it is recommended to work with the I/O driver mmsheet.excel).
Alternatively, it is possible to use the ODBC interface of Excel (NB: this interface is not well supported by Excel, so we don't normally recommend its use) - when selecting the header line of a table as output location you can replace
initializations to "mmsheet.xlsx:grow;skiph;myfile.xlsx"
AnArray as "MyOutRange"
end-initializations
by
initializations to "mmodbc.odbc:myfile.xlsx"
AnArray as "MyOutRange"
end-initializations
after running the latter version the area referred to by the range 'MyOutRange' is updated to the full output area so that the next output using the same range name will get appended to it.
- FICOCommunity Manager
Thanks Susanne. I ended up coding this to work as you suggested. This is working as I want it to work now.
However, I am still not totally finished. I was planning to write to an excel file that is an application attachment. But not I realize that I may not be able to update the app attachment. I notice that there is no insightputappattachment. Is it possible to update the application attachment after I finish writing to a file?
Gary
- FICOCommunity Manager
An Insight scenario is not allowed to modify the app data - you can only upload scenario attachments. Note that there is a possibility to access data from other Insight scenarios via the inter-scenario data access, that is by using the mminsight.scenariodata I/O driver (see the Insight Mosel Reference: https://www.fico.com/fico-xpress-optimization/docs/latest/mminsight/mminsightiodrv_sec_secmminsightiodrv.html).
Otherwise, if you really need to upload app attachments you probably need to work directly with the Insight REST API (see https://www.fico.com/fico-xpress-optimization/docs/latest/insight/rest_api/resource_ProjectResource.html?scroll=path__v1_data_project_-id-_attachments.html) using the functionality of Mosel's mmhttp module.
Related Content
Related Content
READING EXCEL WORKBOOK IN MOSEL
Could you please help me whether Mosel can read a workbook a) if it contains a formula in a column not loaded, b) in a column loaded, and c) if it contains a VBA (.xlsm file : workbook with macros).10 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread5Views0likes2CommentsJava Blaze 6.6, Error: 'Attribute' already exists with a different type definition.
Java Blaze 6.6, Error: 'Attribute' already exists with a different type definition. Hi, For one of our clients, we have to deploy a rule service project which was developed in .NET Blaze ver 6.5 in...3Views0likes1Commentxpress python module: has no attribute
I am trying to use xpress with python for the first time. I have installed Xpress 8.3 32 bit. I am trying to run the first example from A Practical Guide to the New Python Interface for FICO Xpress O...9 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread6Views0likes2Comments