Reading Excel File without using jar file - android

I am new to Android. I want to know whether it is possible to read data from MS Excel file without using any jar files in android?
If it's possible then what's the best approach to do it .

Yes and no.
It's entirely possible to code a complete Excel API to read (and write) an Excel file. But that takes time and a lot of energy, as these formats are huge and complicated. You are practically mirroring the functions of Apache POI or JExcelApi. And these projects are huge.
As I don't know your reason for not using an external library (like an .jar) to read Excel, my answer is: Yes it's possible. Read the excel specification and implement an library to read this format. But practically: Don't do it and use the libraries from above. This will preserve you from a lot of pain.

Related

What are the standard ways of reading and writing audio files on Android / Kotlin?

What are the standard ways of reading and writing audio files on Android / Kotlin?
I am very confused. I've found plenty of posts that discuss this at some level, but they're all either giving a third party answer (someone's own implementation like https://medium.com/#rizveeredwan/working-with-wav-files-in-android-52e9500297e or https://stackoverflow.com/a/43569709/4959635 or https://gist.github.com/kmark/d8b1b01fb0d2febf5770) or using some Java class, of which I don't know how it's related to the Android SDK (https://stackoverflow.com/a/26598862/4959635, https://gist.github.com/niusounds/3e49013a8e942cdba3fbfe1c336b61fc, https://github.com/google/oboe/issues/548#issuecomment-502758633).
I cannot find a standard way from the Android documentation. Some answer said to use https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/java.io.-input-stream/read-bytes.html for reading, but I'm quite sure this doesn't parse the file header.
So what's the standard way of processing audio files on Android / Kotlin?
I'm already using dr_wav just fine on desktop, so I am actually thinking of just using that through NDK and maybe creating a wrapper to it.
Your use case is not clear from the question.
Assuming that you need to process raw audio data (PCM samples) - the standard way is to read the (compressed) input file using the MediaExtractor and decode the packets using the MediaCodec. Note that the documentation includes some example code.
The MediaCodec outputs ByteBuffers containing raw PCM samples. The binary format is described here.
Well, there is no strict standard.
In production, you usually choose stable third party library or your company's reusable internal solution for this kind of tasks. You still can implement it yourself, but it will cost you time, since most likely the implementation will consist of hundreds of lines of code and you probably will just create another variation of existing solution which is present on the internet.

What's the correct way to use JSON files in a library?

I am currently creating an android library that uses json commands for communication with another library. I would like to extract these commands from code and save them in separate files for better readability.
Where do I save those files when there is no asset directory and how do I read them?
Edit: I have found an answer to my question:
how to access resources in a android library project
Have a look at Internal Storage. The files saved here are only available to your app. It uses the Java File API to read an write using the FileInputStream and FileOutputStream
UPDATE:
As per the discussion in the comments, OP was looking for a method to ship a JSON file with the library. In light of that:
I'm not sure if library modules support raw resources. If they do, you might want to use that but it will increase the size significantly. You could also fetch the file from a server the first time you're the library is used, keeping track of that using a SharedPreference entry.

Display MS Document file using apache poi library android

I am able to read the xls document but I don't know how to display it in my application. Do anyone have idea how to display MS Document files using apache poi library?
I have tried searching on google, everywhere only how to read document is mentioned not how to display these document. I don't want to modify the data inside document,Just want to display it.
Thanks in advance
The Apache POI library does not display documents in Android. It is for reading and writing those files, not displaying them. Quoting the mission statement:
The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a complete API for porting other OOXML and OLE2 formats and welcome others to participate.

epub 3 + android + parser + how to

My next project is writting an Android application that would support reading EPUB version 3 files.
I wont be able to use any libraries (that would support this) since i need to write everything from scratch and i cant find any good "starting point" of how to read epub files, how to show them in webview and so on.
So are there any tutorials or how to parse through this epub 3 format and show them in webview
in android.
Any help would be appreciated.
Thank you
I suggest breaking down the problem into smaller pieces that you can research individually:
EPUB uses zip as its container, so you'll need a way to read zip files. If you can't use a library for this, then you could roll your own unzip code. (Example)
Parsing EPUB. If you can't use a third-party library, then you'll need to read the source code for an EPUB library, learn the algorithm(s), and then implement them yourself. The format is based on XHTML, CSS, etc., and should be straightforward to display in a WebView once you understand the layout of the files.
Display the output in a WebView. You can either point the WebView at a local file or pass the markup for a given page directly using WebView.loadData().

Create PDF / Word (Doc) file within app

Is there a definitive method of creating either a PDF or a MS Word Doc file within the app and email it immediately (and possibly, also store it).
I have been trying for quite some time and have found out the JAVA libraries: apwlibrary and iText. But both of them dont provide any tutorials of sorts.
Could anyone point me in the right direction?
EDIT: Come to think of it, is could an online PDF generator be used, first by sending the data to the service, then retrieve the result and save it on the phone?
I would recommend apache fop http://xmlgraphics.apache.org/fop/
you can use standard FOP to generate pdf.
Unless it is a core feature of your device to create a pdf file I would suggest not to do it yourself. Adding PDF creation is going to be quite a lot of work potentially depending on your performance needs. Java libraries will be easier to add but less performant. Native libraries combined with Java will be more hazzle to maintain build and bug fixing wise.
If you just need to email some information why dont you create a message text in html and use a intent to email it with the build in email program instead? Or if you want you could e.g. put the PDF generation on a server and just email a link..
I'm working right now with JasperReports, an open source library to create reports in Java and export them to PDF, DOC, XLS... Using it in conjunction with iReport to create a group of templates makes it really easy to create files filled with content from different types of sources (I'm using JavaBeans).
If you don't like the idea of having static templates (That's a bit annoying depending on your needs), you can always take a look at DynamicJasper (The examples on the website are great).
Good Luck!
I have used Apache POI. It seemed to work well. http://poi.apache.org/
This actually, http://poi.apache.org/hwpf/

Categories

Resources