package motory; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** *

Title:

*

Description:

*

Copyright: Copyright (c) 2003

*

Company:

* @author unascribed * @version 1.0 */ public class startservlet extends HttpServlet { private static final String CONTENT_TYPE = "text/html; charset=windows-1250"; //Initialize global variables public void init() throws ServletException { } //Process the HTTP Get request public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(CONTENT_TYPE); PrintWriter out1 = response.getWriter(); // ----------- short rownum; int cellnum = 0; // synchronized(this){ //----- /*POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("c:\\lista.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.createRow((short)(sheet.getLastRowNum()+1)); HSSFCell cell = row.getCell((short)0); if (cell == null) cell = row.createCell((short)0); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("a test"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream(new File("c:\\lista2.xls")); wb.write(fileOut); fileOut.close(); ///---- */ /* HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet1 = wb.createSheet("new sheet"); HSSFSheet sheet2 = wb.createSheet("second sheet"); HSSFRow row = sheet1.createRow((short)(sheet1.getLastRowNum()+1)); FileOutputStream fileOut = new FileOutputStream("c:\\workbook.xls"); HSSFCell cell ; cell = row.createCell((short)0); //cell.setCellStyle(HSSFCell.CELL_TYPE_NUMERIC cell.setCellValue(10); wb.write(fileOut); fileOut.close();*/ POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("c:\\workbook.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row = sheet.getRow(2); HSSFCell cell = row.getCell((short)3); if (cell == null) cell = row.createCell((short)3); //cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("a test"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("c:\\workbook.xls"); wb.write(fileOut); fileOut.close(); /* for (Enumeration e = request.getParameterNames() ; e.hasMoreElements() ;) { e.nextElement(); cellnum++; } System.out.println(cellnum);*/ /*for (int t=0;t"); out1.println("startservlet"); out1.println(""); out1.println("

The servlet has received a GET. This is the reply.

"); out1.println(""); } //Process the HTTP Post request public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } //Clean up resources public void destroy() { } }