Issue with Excel DecisionTable to load from newClasspathResource - excel

There is some issue with the implementation of DecisionTable in Excel file, if i am using newClasspathResource to load the excel file, where as if i use newFileResource with path of the file it works fine with the same file.
The Exception is:
Caused by: org.drools.template.parser.DecisionTableParseException: An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader.
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:85)
at org.drools.decisiontable.SpreadsheetCompiler.parseResource(SpreadsheetCompiler.java:126)
at org.drools.decisiontable.SpreadsheetCompiler.getRuleSheetListener(SpreadsheetCompiler.java:185)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:172)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:167)
at org.drools.decisiontable.DecisionTableProviderImpl.compileResource(DecisionTableProviderImpl.java:81)
at org.drools.decisiontable.DecisionTableProviderImpl.loadFromResource(DecisionTableProviderImpl.java:44)
at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:37)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:404)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDecisionTable(KnowledgeBuilderImpl.java:374)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addKnowledgeResource(KnowledgeBuilderImpl.java:766)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:2249)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:211)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:168)
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:83)
... 47 more

I think i found the reason, why this was a problem. Actually with my gradle builds, i was processing and filtering some resources and realised that xls file being in resources as well, was being processed through it and somehow being changed while in compiled build path.
I skipped this file to pass through those filtering and processing via build and all is good.

Related

wildcard can’t be used in wholeTextFiles

I try to save the XML files from the folder/subfolders as wholeText file but when I try to use
sc.wholeTextFiles("folder/*/*.xml")
I am getting an error:
llegalArgumentException: 'java.net.URISyntaxException: Expected
scheme-specific part at index
I am using databricks
Identified the route cause of the issue. The problem was “:” in one of the folder caused this issue.. referred github.com/apache/spark/pull/4368

Error accessing file. Network connection may have been lost

So I am using VBA code to open a Excel file, and download data into the worksheet that contains the code.
It worked, now I get the error:
Error accessing file. Network connection may have been lost.
I opened the code to see where it is falling. (I thought maybe the file has changed location or the name has been changed.) When I go through the code (using F8), I immediately get the error on the first line of code (SUB TITLE) and it is marked yellow.
"Error accessing file. Network connection may have been lost"
This (and other generic error messages) can be thrown when the VB Editor detects a discrepancy between the source code (the text you see in the editor) and the compiled binary 'p' code also saved in the workbook. This discrepancy situation is commonly referred to as a "corrupt" workbook.
A temporary fix is to export the modules, forms, and classes one by one, create a new workbook and import them back in. At this point you can now at least edit your source code in order to address the root cause.
However, if the root cause of the corruption is not dealt with in your source code, then whenever the VB Editor next runs/compiles the troublesome portion of your code the corruption in the compiled binary 'p' code will be reintroduced.
This corruption will become apparent only once you have saved and reopened the workbook, at which point the VB Editor will detect the discrepancy between the source code and the binary 'p'code saved in the workbook and throw the error once again.
My solution on the following post gives insight into one such cause of this error due to inadvertently creating a circular dependency in classes that use the IMPLEMENTS statement:
IMPLEMENTS circular dependency issue

drools could not open decision table from XLS file

I could create a fresh spring boot project and successfully run all rules getting from an excel file by following this: http://www.baeldung.com/drools-excel
however If I just add same maven dependencies in my existing spring boot project, I can only use rules in CSV format. if I use .xls, I get error org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0xE011BDBFEFBDBFEF, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
Not sure what am I missing here but I have tried a lot from past 8 hours but no luck
Can anybody suggest please?
I could resolve this after I accidentally tried to open rules excel file on target folder. It was corrupt. It was a maven setup issue. I had to waste a day on this crap issue. this post: Excel file corrupt when copied from src to target in Eclipse IDE
helped me to resolve my issue

Problems came up in the following areas during load: Table

I have generated an excel file from xml. But i can not open it with Excel. Excel gives the following error opening it:
Problems came up in the following areas during load:
Table
Then it shows a message that the log file corresponding the error can be found at : C:/Documents and Setting/myUserName/Local Settings/Temporary Internet Files/Content.MSO/xxxxx.log
But i can not find Content.MSO folder in my windows. I checked folder settings and made all folders visible but i still can not access this folder. So that i can not analise the log file.
how could i find the generated log file?
I found the problem without analising the log file. i stil can not access the log file in temporary internet files. But i realised that i put a string(non-number) characters on a number-styled cell in Excel xml. So if you having the similar issues about your Excel file generated from xml, then have a look at if your cell values are appopriate with your cell data type.
If you type or paste the path of the log file into Explorer or your text editor of choice, you may find that the folder does exist, despite being invisible.
In my case it was a <Row> with an incorrect ss:Index
I was using a template and the last row had a fixed Index=100. If the number of rows I added exceeded 100, this last row had a wrong index and excel threw the error without any other message or log (MacOSX, Excel 15.25.1). I wish they printed more informative error messages, what a waste of our time.
Excel 2016. My error message was "Worksheet Settings". Path was pointing to non-existing file.
My cause of the problem was ExpandedRowCount not big enough for number of rows in Worksheet. If you add rows in XML directly (i.e. on a machine where Excel is not installed), make sure to increment number of rows in ExpandedRowCount.
yes.Even i too faced the same problem and problem was with the data type of cells ofexcel generated using xslt
In addition to checking the data being used vs "Type" assigned, make sure that the list of characters that need to be encoded for XML are indeed encoded.
I had a system that appeared to be working, but then some user data including & and < was throwing this error.
If you're not sure what's going on with your file, try http://www.xmlvalidation.com/ - that helped be spot the issue in a large file immediately.
I used this function to fix it, modified from this post:
function xmlsafe($s) {
return str_replace(array('&','>','<','"'), array('&','>','<','"'), $s);
}
and then run echo xmlsafe($myvalue) where you were just echoing $myvalue in your script.
This seems to be more appropriate for XML than htmlentities() or other options built into PHP.
I had the same issue, and the answer was - type of Cell was Number and some values doesn't converts to this type on my backend.
I had the SAME problem,
and its because de file is TOO BIG.
I try an extract from SAP, more little than the one with that make the error) and save it in XML file. and it WORK, no more error.
so maybe if you can save in 2 Excel files XML instead of 1 it will be good ;)
ALicia

MVC3 return File action causes intermittent Excel program error

I have a problem that closely relates to this problem Microsoft Excel Error: "There was a problem sending the command to the program." whereby opening Excel gives There was an error sending a command to the program error.
However, rather than the file existing and being opened or shortcutted-to, I am using MVC3 with an action that generates a bunch of data, generates an excel file (using NPOI), writes it to a MemoryStream and then chucks that to the browser using the built-in return File(etc) ActionResult, with something akin (but shortened here to aid readability) to this:
return File(myMemoryStream, "application/vnd.ms-excel", "filename.xls");
The first time you click the link which fires this action and returns this File - it comes up with the error. if you press ok and try it again it works, and will continue to work... forever
Now I know this is potentially something to do with disabling DDE/plug-ins or something in Excel - but since I'm generating an excel workbook and dumping it to a memory stream rather than opening something that exists permanently on the file system, I'm not sure what options I have to remove the issue.
Any suggestions on how to get around it? Perhaps I have the wrong mime-type?
The Content-Type application/vnd.ms-excel is sending the command to the Browser to open the file in the Browser. Which can be the cause of issue. Try setting the content type to application/x-msexcel.
In your example the browser will try to open an Excel spreadsheet in the browser (if the user has Excel installed).
return File(myMemoryStream, "application/vnd.ms-excel", "filename.xls")
Please make the following change
return File(myMemoryStream, "application/x-ms-excel", "filename.xls")

Resources