Help me please. There is a program that I have not completed. The goal of the task is to create a program in java so that it transfers the html table to excel. I will be grateful.
import java.awt.Color; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import org.apache.poi.hslf.model.AutoShape; import org.apache.poi.hslf.model.Line; import org.apache.poi.hslf.model.ShapeTypes; import org.apache.poi.hslf.model.Slide; import org.apache.poi.hslf.model.Table; import org.apache.poi.hslf.model.TableCell; import org.apache.poi.hslf.model.TextBox; import org.apache.poi.hslf.usermodel.RichTextRun; import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.StringUtil; public class Samplefile { public static void main(String args[]) throws Exception{ System.out.println("test"); File fl=new File("test.html"); FileInputStream finp=new FileInputStream(fl); InputStreamReader isr = new InputStreamReader(finp); BufferedReader buff = new BufferedReader( isr ); StringBuffer strBuff = new StringBuffer(); ArrayList<String> arrstr = new ArrayList<String>(); //читаем строку, а не чар String s; while ( ( s = buff.readLine() ) != null ) { strBuff.append(s); arrstr.add(s); } String str= strBuff.toString(); Workbook wb = new HSSFWorkbook(); CreationHelper createHelper = wb.getCreationHelper(); Sheet sheet1 = wb.createSheet("test"); Row row = sheet1.createRow((short)0); // Create a cell and put a value in it. Cell cell = row.createCell(0); cell.setCellValue(1); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setDataFormat( createHelper.createDataFormat().getFormat("dd.mm.yyyy")); // Or do it on one line. row.createCell(1).setCellValue(1.2); row.createCell(2).setCellValue( createHelper.createRichTextString("This is a string")); row.createCell(3).setCellValue(true); row.createCell(4).setCellValue("ddd"); cell=row.createCell(5); cell.setCellValue(Calendar.getInstance()); cell.setCellStyle(cellStyle); cell=row.createCell(6); cell.setCellValue(new Date()); cell.setCellStyle(cellStyle); cell = row.createCell(7,HSSFCell.CELL_TYPE_ERROR); String file="test.xls"; FileOutputStream outfl = new FileOutputStream(file); wb.write(outfl); outfl.close(); } }
<td></td>
tags, for example. - art