Android Question Printing an xls file

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings, all.

Would this be the best way to print an xls file?

B4X:
Try
  Dim i As Intent
  i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "1.xls"))
  i.SetType("text/xls")
  StartActivity(i)
Catch
  ToastMessageShow("No matching application.", True)
  Log(LastException)
End Try

Is the SetType - i.SetType("text/xls") - correct?

I presume the user then would get choices to open the xls with another app or print with whatever printing app they have?

Second question:

In 4.4, Print Services are included - like Cloud and HP Plugin. What happens then?

Any and all help welcomed.

Thank you in advance.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, NJ.

I had seen your library before, and had responded. You state it does not address the 4.4 environment.

Best regards.

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

The code works but not with the desired results. In the devices in which I tested, the code automatically brought the file into a text editor. (I have WPS and Polaris but it did not bring it into either app). I am a true novice in the area of Intents, but I assume is due to the parameter text in i.SetType("text/xls"). In ES File Manager, when I touch the xls file, it does show WPS and Polaris as well as Hp ePrint as possible apps to choose.

Like a million other developers, I wished that Android provided a simple way of printing aka Windows printer drivers. In the absence of this, NJDude was very generous with his time and did a great job in the Cloud Printing Library - 4.4 has to be addressed (and the library would have to be maintained for future releases of Android - obviously Google appears not to be too big on backward compatibility).

I will post a new thread on questions about Intent:
1. How to pass a file to be printed with HP ePrint.
2. How to issue an Intent passing a file name so that Android gives the user the ability to choose an app that will handle it (and hopefully include HP ePrint or any other Print solution the user has set up).

The Title of the post will be Explicit Intents.

I will read some more on thedesolatesoul tutorial found in:
http://www.b4x.com/android/forum/threads/tutorial-inter-app-communication-with-intents.30608/

Thanks again.

Sandy
 
Last edited:
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
THIS WORKS.

Addendum to previous post:

B4X:
Try
    Dim i As Intent
    uri = "file://" & "file://" & File.Combine(File.DirRootExternal, "book1.xls")
    i.Initialize(i.ACTION_VIEW, uri)
    i.SetType("application/vnd.ms-excel")
    i.WrapAsIntentChooser("Choose XLS Viewer")
    StartActivity(i)
Catch
    ToastMessageShow("No matching application.", True)
    Log(LastException)
End Try

This code brings up the HP ePrint, WPS, and Polaris (if installed) for the user to choose. Tested on 4.3 and 4.4. I wish I knew how to construct the intent. I have no knowledge of:

i.SetType("application/vnd.ms-excel")


HP ePrint does not allow to choose Portrait or Landscape. Also, I have to study more on the creation of the xls related to gridline and to see whether header will repeat on every page...

Code is from http://www.b4x.com/android/forum/members/dxxxyyyzzz.12540/

Post is :

http://www.b4x.com/android/forum/threads/open-xls-file-with-intent.25531/
 
Last edited:
Upvote 0
Top