I have code using Apache POI written to read data from .xls worksheets using hssf. I'd like for the program to read .xlsx worksheets as well using org.apache.poi.ss.usermodel. Here is the code:
(_fileName is passed into the function)
java.io.FileInputStream fs = new java.io.FileInputStream(_fileName)
Workbook book = WorkbookFactory.create(fs);
It throws the following exception for a .xlsx file: InavlidFormatException - Can't read the content types part !
I'm doing this in Visual Studio, so the output window says "A first chance exception of type 'org.apache.poi.openxml4j.exceptions.InvalidFormatException' occurred in poi-ooxml-3.7-20101029.dll'.
And for a .xls file, the output window says "A first chance exception of type 'java.io.IOException' occurred in IKVM.OpenJDK.Core.dll"
It would be great if someone could help me solve this issue. Been working on this since yesterday.
Thank you so much!!!
Soundarya
The error message indicates that your .xlsx file isn't a valid one. I'd double check you're passing in the correct file, and that it's really an Excel one (and not something else - in your .xlsx case I suspect you just have a normal zip file)
Related
I have a json file in sharepoint and I am using Logic Apps to get the json file and dump it into blob storage. Further I need to open that json file in Databricks python using this code
blobstring = blob_service.get_blob_to_bytes(INPUTCONTAINERNAME, INPUTFILEPATH)
myJson = blobstring.decode('utf8')
data = json.loads(myJson)
When I try to open json in python it gives me the following error:
JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig)
After using the "utf-8-sig" as decode I get this error
JSONDecodeError: Unterminated string starting at: line 1 column 103775708
IMPORTANT: When logic app dumps the json from sharepoint on blob, lease state is expired on the blob storage. I downloaded the json from blob and uploaded the same file manually (it made the lease state available) and the python code opened the json perfectly.
I thought it was an issue with lease state so after logic app dumped the json on blob, I made the lease state available with code (so I don't have to download and upload again manually) and tried to open json but received the same errors again.
In my logic app I am using the get file content for getting the file content of the .json file and create blob for creating a blob with the file content.
Can anybody point me in the right direction?
It seems your storage blob has some setting which caused the lease state to expired, the lease state will become "expired" just after acquire the lease. I test it in my logic app(get a file from sharepoint and create blob), its lease state is "available".
And it works fine when I want to get this file in code.
I write a function to read data from excel file, then generate whole datas to JSON. When i test running as application, it works well. But when i call that function into Servlet class and using browser to run it, the file not found exception come. I put the excel file to root folder of my project and URI is the same. Is there any one have ever had same issue with me? and know how to fix it? Thank.
We're constructing a network of data and part of that includes modifying a search query from a public website to pull all of the data we want. That data, however, when pulled is stored into a JSON txt file.
Ultimately we want this data to be stored in an Access Database so the next step, we thought, was to convert it to XML so we can have an Excel sheet to import. We found a formatting tool (http:jsonformatter.org). When running the tool we received the following error:
“Microsoft Access has encountered an error processing the XML schema in file ‘Data.xml’,
A document must contain exactly one root element”
I've no idea what this entails or where to start debugging. Are there alternatives we might consider?
The error says that there is more than one root element. Have you validated the XML generated? I looked at the website. I tried to ask via comment but I don't have enough rep but you should post some of your json and xml.
If I am reading your issue correctly, you are converting json to xml format and then to excel?
I would suggest writing some code to consume the json and export the xml files to import.
I am working on an Excel file that has embedded RExcel and calls a function from R through RApply in thousands of cells. The problem that I encounter is when I try to download some files in CSV format, I obtained a message which states that a severe error has occured and all my Excel files are shut down.
I would appreciate some assistance in what I could do in order to prevent this problem!
Problem
-I have an excel spreadsheet generated a lotus app. It smells and looks like excel but Excel Source data flow source can not recognise it. When trying to select a table(tab) i get the following error message "External table is not in the expected format.”
-Opening the excel spreadsheet and save it again helps(File also reduces in size). But as dev we ara allegic to manual processes.
-I have tried to change the connection string using a variable
from
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataImport\Lotus.xls;Extended Properties="Excel 8.0;HDR=YES";
To
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DataImport\Lotus.xls;Extended Properties="EXCEL 12.0;HDR=YES";
If i can avoid the script task that would be great
I have had to open and close the excel file manually saving. Those bugs that can't be fixed
I had the same error, your post led me to open the excel file but my excel file was corrupt. I'm posting in case this helps someone else.