I'm trying to export data fetched from DB to an excel sheet, when user clicks on excel
icon on the screen in the following way. It actually works fine but just wanted to get a better idea on this rather than reading the buffered data.
private void exportLayout(String date,
PrintWriter prn,
BufferedReader in ) throws Exception
{
String line = null; // Indicates current line
boolean isNotEndofBuffer = true; // boolean to indicate if the end of buffer is reached
boolean skip = false; // boolean to indicate if we can skip reading the current line
try
{
while (isNotEndofBuffer)
{
if (!skip)
{
line = in.readLine();
}
if (line != null)
{
...
ExportUtil.outputLine(prn, TEXT1 +
TEXT2 + TAB +
TEXT3 + TAB );
catch( IOException ioe )
{
ioe.printStackTrace();
throw ioe;
}
catch( Exception ex )
{
ex.printStackTrace();
throw ex;
}
Don't need any code, By using this query you can export database table to excel
Export data from MySQL into a CSV file,Its simple by using this query.
SELECT * INTO OUTFILE '/tmp/name.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM [tablename]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.