convert excel worksheet to sql script

前端 未结 3 2135
醉话见心
醉话见心 2020-12-31 13:00

I have a excel worksheet (.xls). I need to convert it into sql script. The single excel worksheet consists of multiple tables. So the resultant script should have multiple c

3条回答
  •  没有蜡笔的小新
    2020-12-31 13:52

    this is created by vamsi krishna mysore 1.apache apoi should be used it should be added to the files and system apache apoi i sused in this project

      package excelread;
        import java.io.File;
        import java.io.FileOutputStream;
        import java.util.LinkedList;
        import java.util.List;
        import java.util.Scanner;
        import jxl.Cell;
        import jxl.Sheet;
        import jxl.Workbook;
        import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
        import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
        import org.apache.poi.xwpf.usermodel.XWPFDocument;
        import org.apache.poi.xwpf.usermodel.XWPFParagraph;
        import org.apache.poi.xwpf.usermodel.XWPFRun;
    
        public class ExcelRead 
        {
    
            public static void main(String[] args) throws Exception
            {
               try
            {
                FileOutputStream output=new FileOutputStream("result.docx");
          FileOutputStream output=new FileOutputStream("result.sql");//sql script in the script
          FileOutputStream output=new FileOutputStream("result.xlxs");
        FileOutputStream output=new FileOutputStream("result.csv");
                XWPFDocument doc=new XWPFDocument();
                XWPFParagraph para=doc.createParagraph();
                para.setAlignment(ParagraphAlignment.CENTER);
                XWPFRun pararun=para.createRun();
                pararun.setBold(true);
                pararun.setFontSize(20);
                pararun.setText("Database Tables\n\n");
                File f= new File("C:\\Users\\admin\\Desktop\\BUILDING_TB.xls");//file location where it is stored in the system
                Workbook wb= Workbook.getWorkbook(f);
                int sheets=wb.getNumberOfSheets();
                for(int s1=0;s1 comments= new LinkedList ();
                       List  sequence= new LinkedList ();
                       List  cid= new LinkedList ();
                       String createQuery="create table " +tbname+"(";
                       System.out.println(rows+" "+cols);
                        for(int j=0;j

提交回复
热议问题