मैं प्रयोक्ता के लिए अपाचे पोई के माध्यम से डाउनलोड करने के लिए एक्सेल फ़ाइल बनाने का लक्ष्य रख रहा हूं।आउटपुट स्ट्रीम में एक पोई वर्कबुक लिखना अजीब मूल्यों को उत्पन्न कर रहा है
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
// create a workbook , worksheet
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("MySheet");
CreationHelper createHelper = wb.getCreationHelper();
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow((short)0);
Cell cell = row.createCell(0);
cell.setCellValue(1);
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
//write workbook to outputstream
ServletOutputStream out = response.getOutputStream();
wb.write(out);
out.flush();
out.close();
//offer the user the option of opening or downloading the resulting Excel file
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=MyExcel.xls");
समस्या यह है कि मैं इन अजीब मूल्यों हो रही है:
मैं अपने सर्वलेट में इस कोड है
`... MySheetŒ®üÿ» आइए डब्ल्यू © ñÒMbP du? * +, €% ÿÁƒ "¡" d ,, à? À?
किसी भी सुझाव?
यह सही जवाब नहीं था, लेकिन मुझे एक और समस्या से मदद मिली। धन्यवाद :) – tarikki