- <% @ Page contenttype = "application/MSExcel" %>
- <%
- // Open the Excel software independently
- Response. setheader ("content-disposition", "attachment; filename=myexcel.xls ");
- // Nested in IE open Excel
- // Response. setheader ("content-disposition", "inline; filename=myexcel.xls ");
- // For word, you only need to change contenttype = "application/MSExcel" to contenttype = "application/MSWord"
- %>
- <HTML>
- <Head>
- <Title>Test export of Excel and Word</Title>
- </Head>
- <Body>
- <TableWidth = "500" border = "1" align = "center">
- <Tr>
- <TDColspan = "4" align = "center">Electronic Product test statistics</TD>
- </Tr>
- <Tr>
- <TDWidth = "7%">Bar Code</TD>
- <TDWidth = "7%">Voltage</TD>
- <TDWidth = "18%">Current</TD>
- <TDWidth = "68%">Power</TD>
- </Tr>
- <Tr>
- <TD>20061006</TD>
- <TD>Xxx</TD>
- <TD>Xxx</TD>
- <TD>XXXXX</TD>
- </Tr>
- <Tr>
- <TD>20061007</TD>
- <TD>Xx</TD>
- <TD>Xxx</TD>
- <TD>XXXXX</TD>
- </Tr>
- <Tr>
- <TD>20061008</TD>
- <TD>Xx</TD>
- <TD>Xxx</TD>
- <TD>XXXXX</TD>
- </Tr>
- </Table>
- </Body>
- </Html>
Reference page: http://www.javaeye.com/topic/375929
Web pages: http://www.javaeye.com/topic/94817
Http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/
Struts2 uses stream to directly output Excel: http://www.java3z.com/cwbwebhome/article/article2/21102.html? Id = 1890