highcharts-图表导出到word 代码
1、需要的maven包大概是这些,但是我也不太确切,这个应该是最大量
<dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext-rtf</artifactId>
    <version>2.1.7</version>
   </dependency>
   <dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>2.1.7</version>字体代码大全
   </dependency> 
   <dependency>
    <groupId>batik</groupId>
    <artifactId>batik-transcoder</artifactId>
    <version>1.6-1</version>
    <exclusions>
     <exclusion>
      <artifactId>fop</artifactId>
      <groupId>fop</groupId>
     </exclusion>
    </exclusions>
   </dependency>
   <dependency>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis-ext</artifactId>
    <version>1.3.04</version>
   </dependency>
   <dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.10.0</version>
   </dependency>
----------------------------------------------------------------------------------------------------------------------------------------------------
2、Extjs部分
sendRecord数组的部分 内容大概是
[{companyId:1035,
companyName:'上清寺局',
svg :'这里是highchart的svg字符串'             
},{........................},{........................}];
highchart的svg字符串'可以通过生成highcharts实例获得:
var chart = new Highcharts.Chart({}); 
var SVG();
var form = ElementById('exportForm');
    ('autoReportDtos').set({
     value : '{autoReportDtos:' + de(sendRecord) + '}'
    });
   form.action = '../../AutoReportServlet';
    form.target = '#';
    form.submit();
说明:value : '{autoReportDtos:' + de(sendRecord) + '}' 因为要传递中文所以要de();
js的encode()效果也应该是一样的
value值的格式,是因为组织内部使用的json解析工具需要这样的字符串格式
{autoReportDtos:[{............},{..................},{..................}}
List<AutoReportDto> autoReportDtos = JsonParseUtil.jsonStrToList("autoReportDtos", autoReportDtosStr, AutoReportDto.class);
会解析为List<AutoReportDto>
----------------------------------------------------------------------------------------------------------------------------------------------------
3、servlet部分
 package s.app.servlet.sys;
import java.awt.Color;
import java.io.StringReader;
import java.URLEncoder;
SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.anscoder.Transcoder;
import org.anscoder.TranscoderInput;
import org.anscoder.TranscoderOutput;
import org.anscoder.image.JPEGTranscoder;
import t.ApplicationContext;
import org.t.support.WebApplicationContextUtils;
import s.app.utils.JsonParseUtil;
import s.base.dto.sys.AutoReportDto;
import s.base.dto.sys.InstallMoveFixReportDto;
import s.base.dto.sys.InstallMoveOrderReportDto;
import s.base.dto.sys.MonthCompletedConditionDto;
import s.base.dto.sys.TimeoutWarningOrderDto;
import port.service.sys.ReportService;
import Cell;
import Document;
import Element;
import Font;
import Image;
import PageSize;
import Paragraph;
import Rectangle;
import Table;
import tf.RtfWriter2;
import tf.style.RtfFont;
import l.messaging.saaj.util.ByteOutputStream;
public class AutoReportServlet extends HttpServlet {
 private static final long serialVersionUID = 734049956945955588L;
 protected void doGet(HttpServletRequest request, HttpServletResponse response) {
  doPost(request, response);
 }
 protected void doPost(HttpServletRequest request, HttpServletResponse response) {
  // response.setCharacterEncoding("UTF-8");
  // request.setCharacterEncoding("UTF-8");
  try {
   response.setContentType("text/html;charset=UTF-8");
   String autoReportDtosStr = Parameter("autoReportDtos");
   autoReportDtosStr = new Bytes("iso-8859-1"), "utf-8");
   List<AutoReportDto> autoReportDtos = JsonParseUtil.jsonStrToList("autoReportDtos", autoReportDtosStr, AutoReportDto.class);
   ByteOutputStream bos = new ByteOutputStream();
   
   ApplicationContext applicationContext = ServletContext());
   ReportService reportService = (ReportService) Bean("reportService");

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。