My application generates data and i want to share this data, like transfer to my PC and work or send it to others as excel sheet.
Can we store data from an android application to a Excel sheet programatically ? Then how do we open and Excel file and write to it ?
In theory, libraries like Apache POI and JExcel should work on Adroid but there are some issues with them at this point.
Only option is to generate XL that can be read by Excel. Steps are:
Create an Excel file on PC with formatting that you need
Save that file as XML, Excel will insert Tags for formatting/ formulas
Write java code to generate similar XML file on Android
On Android, save this XML file on SD Card
Transfer the XML to PC and open that in Excel
Take a look at this tutorial, How to create file in SD-Card.
Related
I am currently using Apache POI to enter data into Excel file. The only problem is I can not keep the file open if I have to append data to the same file. Are there any specific sample codes which would allow me to do so?
My basic requirement is to fetch Runtime data from a place (this I am able to do) and add it to the Excel sheet while the file is still open.
Any suggestions?
I don't think that this is possible without a C# addon or some kind of macro. You could write a simple C# addon for Excel that connects to your java programm and recieves the realtime data. The addon will write it to the spreadsheat then.
So, i building an application that doing that:
when the user write a name in edittext and click a button, i want the application to give the user some information about this name,
I have an Excel with that information, how can i add this Excel into my apk
And how can i read it from there? for each name his specific information..
the Excel look like that:
http://s18.postimg.org/ofcgudlk9/image.jpg
So for example, when the user write "android" in the edittext and click the button, i want a toast that will show "number: 1234 , more: good"
Any Idea?
you can use JExcelApi library to read or write to an Excel file , you have to put your excel somewhere in Sdcard then with jxl you can read or write to it.
Don't put the Excel file in your app.
You can export the excel file as a CSV file.
Then you can use the csv file with your app or you can use it to create a SQLite database and distribute it with your app.
The csv or SQLite file goes into the assets directory.
You can use OpenCSV to parse the CSV file.
To distribute an SQLite file with your app you can use SQLiteAssetsHelper.
I would prefer Json instead of using an excel or CSV file as suggested in other answers. With Json you can easily read and search through your data.
So here is the approach,
Convert your Excel to Json here -> http://shancarter.github.io/mr-data-converter/ Note: Just a service
that I found in Google. You may search for better services.
Now place the Json in /res/assets folder. If there is no assets folder then create it.
Now Load the Json at the start of your application. Google about parsing Json files, If you are not aware of it.
Whenever user enters something, Please search the Json and show the respective content.
Hope it helps.
you may try use POI HSSF/XSSF to just read the excel file.
I need to write one java program which monitors a folder containing excel sheets (.xls format) . Once a new excel sheet is added I have to update the database in db2 and move the excel sheet to other place.
Please suggest
It sounds like you need to get notified if files appear in a directory. Java 7 has good support for this, see this article about the Watch Service API. The db2 part, well it isn't clear what you mean by "update", but likely you want to parse the content of the xls file and make some database updates. Apache POI is a good starting place for reading the content of the file into a Java process.
I am working on a java web application where i have to show an image on excel file.
i used the java file iopo to write the image to the excel file.
Issue is when the user mail this to client the image does not show up
Is there any way to embed the image into the excel file using java with/without using any external API.
You can use Apache POI: http://poi.apache.org
See especially http://poi.apache.org/spreadsheet/quick-guide.html#Images
You must use an external library as there is no standard Excel API for Java.
You should use something along the lines of JExcelAPI.
Related to this question, how to save many different csv files into one excel workbook with one sheet per csv ? I would like to know how to do this programmatically in Java.
You'll need some form of library for accessing Excel from Java. A Google search turned this one up:
http://j-integra.intrinsyc.com/support/com/doc/excel_example.html
An alternative is to use the XML Excel format that came into being with Office 2003. You'll end up with a XML file, but you can open it in Excel and see the different sheets.
http://www.javaworld.com/javaworld/jw-07-2004/jw-0712-officeml.html
If you want open source, the POI library can be used to generated Excel files.
A nice CSV parser is Open CSV
That should set the stage for what you are trying to do (basically use the CSV parser to get data, then write the data to an XLS file.
Take a look at the Aspose products, I've used them before when working with Excel and they saved me a huge amount of headache and time. Excel has several quirks that can make importing and exporting spreadsheets painful.
Aspose.Cells