Word 테이블의 테이블 생성 자동 테이블 추가

오늘은Word 템플릿을 통해 프론트 데스크톱에서 Flex를 통해 데이터를 작성하고 마지막으로Word 문서를 작성하는 자동화된 SDD 문서를 만드는 작은 도구를 만들고 있습니다.
다음은 일부 코드로 표에 대해 자동으로 표 내용을 추가합니다

import java.util.ArrayList;

import com.heavenlake.wordapi.Document;

public class test
{
    public test()
    {
        Document doc = null;
        try {
          doc = new Document();
          doc.newDoc("e:/test4.doc");
          doc.insertln("    ");
          doc.insertln("        ");
          //doc.saveAs("e:/test2.doc");
                ArrayList tableData = new ArrayList(3);
                String[] title = {
                    "  ", "  ", "  ","  "};
                tableData.add(title);
                String[] field1 = {
                    "1", "751002", "           ","www.heavenlake.com"};
                tableData.add(field1);
                String[] field2 = {
                    "2", "751004", "        ","pdm.heavenlake.com"};
                tableData.add(field2);

          doc.insert(tableData,"   ");

          doc.insertln();
          
          
          ArrayList tableData1 = new ArrayList(3);

          String[] field3 = {
              "1", "751002", "           ","www.heavenlake.com"};
          tableData1.add(field3);
          String[] field4 = {
              "2", "751004", "        ","pdm.heavenlake.com"};
          tableData1.add(field4);
          doc.replaceTable(1, 4, tableData1);

        } catch (Exception e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                if (doc != null)
                    doc.close(true);
            } catch (Exception e)
            {
                e.printStackTrace();
            }

        }

    }

    public static void main(String[] args)
    {
        test test1 = new test();
    }

}


좋은 웹페이지 즐겨찾기