Report / word doc output ?

ljcomp

Member
Licensed User
Longtime User
Hi All
I am writing an app for a tablet using sqlite database to capture survey data in the field. I want to then create a report having words and tables, most of which is static but some need to be replaced by relavent fields from a data set.

The database is working well but I have no idea how to progress.

Ie If I have a word doc like:-

"We have been instructed by ****** to carry out a survey"
I would want to insert the ****** text from a database col.

I have a table of 2 cols and 3 rows, in each box I would want to insert a number then the value from a database

When the form / report / word doc whatever is completed I need to print it or send it to a pc for printing.

If this makes sence to anyone would you please point me in the right dirrection.

Many thanks

Lj
 

ljcomp

Member
Licensed User
Longtime User
Wow that was quick mate
Having a blonde moment, how would I open and edit the HTML from basic4android ?

I assume I create the HTML outside of basic4android. Open the file with my app and input varriable data. Then show the file in a webview.

LJ
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
One way of doing it.

Of course there is another more efficient and quick way of doing it but this is a quick example that hopefully will give you an idea.
 

Attachments

  • Sample.zip
    11.1 KB · Views: 320
Last edited:
Upvote 0

ljcomp

Member
Licensed User
Longtime User
Thanks for that, Problem I got is the size of the html page I need to generate.
Is there a way to write mutilpe lines of html.
ie in PHP I can use
ECHO <<<END
html 1
html 2
etc
etc
END

LJ
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
No, but you could read the contents of your HTML and then "replace" the fields you need, for example:
B4X:
<html>
<body>

<table border='1'>
  <caption>User Info</caption>
  <tr>
    <th>User Info</th>
    <th>Data</th>
  </tr>
  <tr>
    <td>First Name</td>
    <td>$First</td>
  </tr>
  <tr>
    <td>Last Name</td>
    <td>$Last</td>
  </tr>
</table>

</body>
</html>

Then you could do this:
B4X:
HTML = HTML.Replace("$First", Main.FirstName)

You can create your HTML with an editor, do you get the idea?
 
Last edited:
Upvote 0

ljcomp

Member
Licensed User
Longtime User
Ah thats looking more usable..

Assuming I could read the html file into HTML with
B4X:
 HTML = File.OpenInput(File.DirRootExternal & "/treescape/","bs.html")

Failed with (BufferedInputStream) java.io.BufferedInputStream@4077de8

Any idea what this means ?

My first thought was HTML file too large, it's about 1MB inc images.
 
Upvote 0

ljcomp

Member
Licensed User
Longtime User
Many thanks mate
I was almost there should have used
B4X:
HTML = File.GetText(File.DirRootExternal & "/treescape/","bs.html")

Works a treat except for no images show in the webview.
Will check my html and the image folder.

LJ
 
Upvote 0

ljcomp

Member
Licensed User
Longtime User
Thanks for that
Looks like I can use what I have learned so far to text replace in the html file.
Then save the new html as a new file. Assuming the img tags of the html are not altered, the new file should render correctly in a browser.

LJ
 
Upvote 0
Top