Could some one give an idea about how to convert an excel file into a CLOB in oracle through JDBC. I would like to know how to covert excel file into a String using API available as part of JDK and the conversion from string to clob should be straight forward. Thanks in advance. If a similar question was already raised, kindly provide me the link.
You will need a library out side of the standard java api to read a binary excel document.
You could use the JExcelApi to read in the Excel document then create a CSV String as you read in the document.
If you don't want to use an outside library then I would change the field type to blob and use the setBlob method of java.sql.PreparedStatment passing it a FileInputStream.
When you need to parse the data (read the contents) you can use a library like Apache POI
If you want to use the only standard API, then save the excel as CSV file and process the file as a comma seperated value list. That can easily be done with readline to read each line and split that line to values using the split method on a String.
If you do not need to parse data you should stream the data directly from file to a CLOB and not first transform the excel to a String
An example can be found here: http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
What is the representation of a spreadsheet in text format? The values indented by tabs? The formulas? What if you have more than one page in the xls file?
If what you really whant to do is to store the file in the database use a BLOB and store it as bytes.
Related
I am working in building a project management tool,using MEAN(Mongodb,Expressjs,Angularjs,Nodejs) Stack.
I have a requirement in my project, where users will upload any kind of excel or csv format file and i need to parse each row from the file(excel|csv) and map it to my database model and save it has a mongodb document.I am trying to find an excel and csv parser library to accomplish my task.I also came accross xlsx, it looks good but it doesnt support reading csv files.It will be really helpful if any one could suggest a node.js library that can read all kinds of excel and csv file formats efficiently.Thanks in advance
At one point, I used Node CSV https://github.com/wdavidw/node-csv
to get the data inputted, it's really easy to use. Most of my users were fine with just having the CSV format option.....but you could combine the functionality of each library depending on the file type entered.....
I was wondering if it is possible to use the code saved in the .txt file using the application.savetotext and save the code in a table, then use the application.loadfromtext to to build the object from a string rather that a .txt file
Does that make any sense? Basically I'm wanting to store all the object codes in a table on separate rows and allow users to select the relevant row and build the object without having to import the .txt file
Yes and no. You would have to write the field content to a (temp) file, then use LoadFromText to read in the object.
But it doesn't make much sense, and I think you are on a wrong track. You could just as well have the objects ready-made in application.
How can I get data passed from NodeJS into placeholders of a OpenOffice template file? Is there any npm packages available to parse an ODT template file so that I can print data into it?
I have a 13 page word file (a template for printing reports) and I want to populate it with certain details from the DB into the different pages of this file. I like to pass the data in JSON format.
What I know is how to write into a plain text/excel file from node, but I want to write into the placeholders of a word template without loosing other parts of the template. I did the same with VBScript (with microsoft word template) in the past. Now want to achieve the same using nodejs. Please share with me your ideas..thanks
I am using the OpenXML SDK to manipulate my Excel files.
I'd like to store some custom XML data in the xlsx file (not in the sheet cells) in a way that survives a roundtrip through Excel.
Is it possible to do this with the CustomXmlPart class? Or some other class? If so, how?
CustomXmlParts are one way to do it. But here's another set of ways: How can I embed any file type into Microsoft Word using OpenXml 2.0 (Word/Excel = same concept)
How to upload a excel's data into a List or DataTable without saving and then deleting the excel file?
I use asp.net C#.
For example, I have a excel file with some data, and I want to get the data from the excel file into a List or DataTable without saving the excel into a file system and then deleting the excel file. So I can avoid the IO operation.
Its doable, but it depends on the type of Excel file.
If its a CSV, you can use a StreamReader on the response stream to parse the CSV line by line. You can then use the TextFieldParser (don't be scared by VisualBasic in the namespace!) to parse the CSV from the stream. Here's a link with some info about the TFP.
If you're talking about a .xls or an .xlsx, it depends on the libraries you use. Different libraries will do things differently, but most likely they will take a stream that contains the file (whether that stream is a FileStream or a response stream--gotta love polymorphism!) and load it from there.
SpreadsheetGear for .NET can read from / write to files, streams and memory (byte arrays) and has a method to get a DataTable from a range of cells (IRange.GetDataTable(...)).
You can download a free trial here if you want to try it out.
Disclaimer: I own SpreadsheetGear LLC