During my grails application i have to urgently produce a file in current system by which i have to save information fetched from table in database.

I've produced file as,

File file=new File("file title.txt")

file.createNewFile()

i quickly have authored values of mysql db table fields inside it as,

file<<patient.id
file<<patient.name
.
.
.

it stores data like continous text but i wish to possess a .doc file by which data should get saved in table.On searching i discovered APACHE'S POI for creating doc file but i'm not getting how it operates and just how i ought to utilize it.

With advance thanks, Laxmi.p

It's complicated to the stage from it not worth any persons effort to create tables (that don't at random break) in HWPF. If you're able to use docx then your XWPF packages are simple to accomplish this with.

import org.apache.poi.xwpf.*

class DocumentUtil {

    public static XWPFDocument makeDocument(metaData, tableData) {
        //make document and apply metadata, like regular text, headings bla bla
        def doc = new XWPFDocument()
        def table = doc.createTable(metaData.rows, metaData.cols)
        table = popuLateTable(table, tableData) //implement this part yourself

        return doc
    }
}

Should you cant use docx, I'd reccomend opting for an stand out document(HSSFWorkbook, even simpler) or simply an easy rtf (that is essentially text with annotations for styling).

Edit: That We see continues to be pointed out inside a comment further up here.