L ljcomp Member Licensed User Longtime User Apr 14, 2012 #1 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
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
NJDude Expert Licensed User Longtime User Apr 14, 2012 #2 You could create an HTML, that would be the simplest way. Upvote 0
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #3 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
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
NJDude Expert Licensed User Longtime User Apr 14, 2012 #4 Yes, you could do that for example, or you could also create the HTML dynamically. Upvote 0
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #5 Don't suppose you can point me at an example I could learn from ? Upvote 0
NJDude Expert Licensed User Longtime User Apr 14, 2012 #6 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 Sample.zip 11.1 KB · Views: 583 Last edited: Apr 14, 2012 Upvote 0
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.
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #7 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
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
NJDude Expert Licensed User Longtime User Apr 14, 2012 #8 No, but you could read the contents of your HTML and then "replace" the fields you need, for example: Code: Copy <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: Code: Copy HTML = HTML.Replace("$First", Main.FirstName) You can create your HTML with an editor, do you get the idea? Last edited: Apr 14, 2012 Upvote 0
No, but you could read the contents of your HTML and then "replace" the fields you need, for example: Code: Copy <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: Code: Copy HTML = HTML.Replace("$First", Main.FirstName) You can create your HTML with an editor, do you get the idea?
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #9 Ah thats looking more usable.. Assuming I could read the html file into HTML with Code: Copy 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
Ah thats looking more usable.. Assuming I could read the html file into HTML with Code: Copy 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.
NJDude Expert Licensed User Longtime User Apr 14, 2012 #10 Ok, this is a sample to do what I mentioned on my previous post. Attachments HTML_Sample.zip HTML_Sample.zip 8.7 KB · Views: 575 Upvote 0
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #11 Many thanks mate I was almost there should have used Code: Copy 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
Many thanks mate I was almost there should have used Code: Copy 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
NJDude Expert Licensed User Longtime User Apr 14, 2012 #12 You need to add a line like the one below to add images to your HTML: Code: Copy <img src='file:///android_asset/MyAwesomePic.jpg'/> Upvote 0
You need to add a line like the one below to add images to your HTML: Code: Copy <img src='file:///android_asset/MyAwesomePic.jpg'/>
L ljcomp Member Licensed User Longtime User Apr 14, 2012 #13 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
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