|
|
@@ -6,11 +6,9 @@ import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
-import com.aspose.cells.License;
|
|
|
-import com.aspose.cells.PdfSaveOptions;
|
|
|
-import com.aspose.cells.SaveFormat;
|
|
|
-import com.aspose.cells.Workbook;
|
|
|
+import com.aspose.cells.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
@@ -41,12 +39,18 @@ public class ExcelToPdf {
|
|
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
|
|
//得到输入流
|
|
|
InputStream inputStream = conn.getInputStream();
|
|
|
+
|
|
|
+ //TxtLoadOptions lo = new TxtLoadOptions();
|
|
|
+ //lo.setEncoding(Encoding.getUTF8());
|
|
|
Workbook wb = new Workbook(inputStream);// 原始excel路径
|
|
|
|
|
|
- PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
|
|
|
+ PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(SaveFormat.PDF);
|
|
|
pdfSaveOptions.setOnePagePerSheet(true);
|
|
|
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
|
|
|
+ pdfSaveOptions.setDefaultFont("SimSun");
|
|
|
+ pdfSaveOptions.setEmbedStandardWindowsFonts(true);
|
|
|
response.setContentType("application/pdf");
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
OutputStream output = response.getOutputStream();
|
|
|
wb.save(output, pdfSaveOptions);
|
|
|
output.flush();
|