Java code to convert google drive spreadsheet to excel - java

Need Java Code to convert Google Drive Spreadsheet to Excel. Later I want to send the converted file as mail attachment.
I am using this code to retrieve the file metadata -
services.files().get(fileObj.getId()).executeAsInputStream();
I have a code to send the mail, but the problem is if I use the above code, the attachment is like a link to Google Drive document.

The File object has exportLinks property that
"Links for exporting Google Docs to specific formats."
exportLinks.(key) can be used to get the link for a specific format. Replace the key with the mimeType you want the file exported to (if I remember correctly)
You can find more info about the exportLinks keys (and Document Downloading in general) here

Related

Sharepoint site Excel file operations using Java graph apis

Would like to create the excel file on sharepoint site using Java Graph API , also would like to get the id of the same file so that modifications on the file can be done using the Graph API.
One should have the Drive Id , Site Id handy for doing this.
Create a folder on your sharepoint site , share the same folder in one drive so that the paths can be used to upload the excel file.
Use the below given link for more information.
https://rahul-metangale.medium.com/upload-a-file-to-sharepoint-using-azure-graph-api-9deacce57449
There is more to this than specified in this blog.

Saving a file in Google Drive from Android

Good morning, I am trying to write a simple Android app that just stores a file in Google Drive so that I can retrieve it from other locations. I followed the examples on the Google tutorial, and I'm using exactly their code, but the result produces no error and my file doesn't get stored.
Since I'm using exactly the example code, can anyone suggest what my next step might be to try to get this working?
Edit with more information:
I'm using the google quickstart example here:
https://developers.google.com/drive/api/v3/quickstart/java
and tried to combine this drivesample in order to upload a file:
https://github.com/google/google-api-java-client-samples/blob/master/drive-cmdline-sample/src/main/java/com/google/api/services/samples/drive/cmdline/DriveSample.java
I was expecting to see the result when I go to my google drive page on my computer.
Edit Again: Perhaps my attempt to work the two of these together is what I'm doing wrong. I will also accept as an answer any link to a good step by step tutorial to simply uploading some bytes to Google Drive that will show up as a file!
If you are looking for a reference on how to upload files using Drive API in Java, you can refer in this official document Upload file data.
Simple upload - upload the media only, without any metadata.
Multipart upload - upload both the media and its metadata, in a single request
Sample Java Code (Multipart Upload):
File fileMetadata = new File();
fileMetadata.setName("photo.jpg");
java.io.File filePath = new java.io.File("files/photo.jpg");
FileContent mediaContent = new FileContent("image/jpeg", filePath);
File file = driveService.files().create(fileMetadata, mediaContent)
.setFields("id")
.execute();
Note: Your FileContent() expects a file type in its first parameter, you can choose for a specific file type based on the MIME Types provided under the additional references
Additional References:
Class FileContent
Google Workspace and Drive MIME Types
Google Workspace documents and corresponding export MIME types
Google Drive API in Android Studio Tutorial (PART 1)
Google Drive API in Android Studio Tutorial (PART 2)
Upload PDF files to Google Drive using Google Drive SDK in Android Studio PART 3

How to change attachment of Outlook .msg file with Apache POIFS/HSMF

I am working on some project that requires changing attachments of an Outlook .msg file.
I chosen to use Apache POI with its low-level POIFS API.
I am able to substitute binary data of an attachments by re-writing PR_ATTACH_DATA_OBJ ByteChunk, as well as few other Chunks related to filename, extension, displayName.
However, when I open the resulting .msg file in outlook my attachments viewed as no-extension file but content is exact what I have pushed to it:
There are two more fields that I can't find possible data to write as well as there is no description for them in MAPIProperty.Java POI dictionary:
Can somebody advice me how I can make attachment substitution possible to success? What kind of data I have to put into these two fields in order to fix preview? Will this help?
I am looking for a free solution. I already tried Aspose.Email and this works brilliant but it is not currently an option.
Embedded message attachment (stored in PR_ATTACH_DATA_OBJ property on an attachment) is not a file.
Does Outlook correctly open the attachment? Make sure the attachment type remains the same.

How to extract required data from .prn (pcl6) file by using java..?

// extract data from .prn
How can i extract data from a printer generated dumb .prn file (pcl6) by
using java or any other language. Is there any java Api for this ,like
Api for pdf file read (iText). I have googled alot but not found
anything usefull yet.
Thanks to all...
A .prn file will contain codes for whatever specific printer it was
generated for, If you know these Codes you can extract them, the rest would be plain text which can then be saved to normal .txt file.
A Workarround would be to convert it to pdf and get content and how it but i dont think this is simple programmatically. therefor you can use a PDF printer driver such as CutePDF or GhostPCL

Use Google Docs API to download file of any type

Is it possible to download files of any type from Google Docs using the Google Docs API? (jpg, zip, txt)
I can figure out how to download word, powerpoint, and excel files but want to be able to upload and download any type of file to Google Docs. I know it is possible to do this with the online uploader but can't seem to get the downloading part to work with the API.
I'm using the Java wrapper to the API. Is it possible to use the Java version of the API to download all file types?
Since the last answer was written, that API is deprecated. There's sample Java code on the Google Dev page for the (newer) Google Drive API for managing downloads from Google Docs.
This handles a large variety of MIME types.
See this page http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html
and this for specifically downloading documents and files
http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#DownloadingDocsAndFiles
The document listing XML returned by google has file type and the URL to download the file in the node. You can use the URL to download the file contents.

Categories

Resources