|
|
@@ -6,7 +6,12 @@ import com.lc.ibps.components.verification.model.InspectionConfigVO;
|
|
|
import com.lc.ibps.components.verification.model.InspectionItemVO;
|
|
|
import com.lc.ibps.components.verification.model.InspectionVO;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFChart;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.junit.Test;
|
|
|
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.time.LocalDate;
|
|
|
@@ -17,11 +22,11 @@ public class PVTest {
|
|
|
@Test
|
|
|
public void testExcelImport() throws FileNotFoundException {
|
|
|
|
|
|
- InspectionConfigVO config = new InspectionConfigVO("批内精密度",1,2,
|
|
|
- new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
|
|
|
+ InspectionConfigVO config = new InspectionConfigVO("批内精密度", 1, 2,
|
|
|
+ new String[]{"高溶度(R1)", "低浓度(R2)"}, 10, LocalDate.now(), true);
|
|
|
InspectionItemVO item = new InspectionItemVO(config);
|
|
|
|
|
|
- File file = new File(String.format("C:/tmp/%s.xlsx",config.getName()));
|
|
|
+ File file = new File(String.format("C:/tmp/%s.xlsx", config.getName()));
|
|
|
FileInputStream in = new FileInputStream(file);
|
|
|
|
|
|
item.importExcelRecord(in);
|
|
|
@@ -40,12 +45,12 @@ public class PVTest {
|
|
|
// InspectionConfigVO config = new InspectionConfigVO("正确度",5,2,
|
|
|
// new String[]{"L2","L4"},2, LocalDate.now(),true);
|
|
|
|
|
|
- InspectionConfigVO config = new InspectionConfigVO("线性范围",1,7,
|
|
|
- new String[]{"E8","E7","E6","E5","E4","E3","E2"},3, LocalDate.now(),true);
|
|
|
+ InspectionConfigVO config = new InspectionConfigVO("线性范围", 1, 7,
|
|
|
+ new String[]{"E8", "E7", "E6", "E5", "E4", "E3", "E2"}, 3, LocalDate.now(), true);
|
|
|
|
|
|
InspectionItemVO item = new InspectionItemVO(config);
|
|
|
Workbook workbook = item.exportExcelTemplate();
|
|
|
- FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx",config.getName()));
|
|
|
+ FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx", config.getName()));
|
|
|
workbook.write(fos);
|
|
|
fos.close();
|
|
|
}
|
|
|
@@ -81,13 +86,13 @@ public class PVTest {
|
|
|
// item3.importExcelRecord(in3);
|
|
|
|
|
|
//线性范围
|
|
|
- InspectionConfigVO config4 = new InspectionConfigVO("线性范围",1,7,
|
|
|
- new String[]{"E8","E7","E6","E5","E4","E3","E2"},3, LocalDate.now(),true);
|
|
|
+ InspectionConfigVO config4 = new InspectionConfigVO("线性范围", 1, 7,
|
|
|
+ new String[]{"E8", "E7", "E6", "E5", "E4", "E3", "E2"}, 3, LocalDate.now(), true);
|
|
|
|
|
|
- config4.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE,FunctionEnum.TARGET,FunctionEnum.LRE,FunctionEnum.R});
|
|
|
- config4.setTargetValue(new double[]{8.48,7.48,6.48,5.48,4.48,3.48,2.48});
|
|
|
+ config4.setFunc(new FunctionEnum[]{FunctionEnum.AVERAGE, FunctionEnum.TARGET, FunctionEnum.LRE, FunctionEnum.R});
|
|
|
+ config4.setTargetValue(new double[]{8.48, 7.48, 6.48, 5.48, 4.48, 3.48, 2.48});
|
|
|
InspectionItemVO item4 = new InspectionItemVO(config4);
|
|
|
- File file4 = new File(String.format("C:/tmp/%sdata.xlsx",config4.getName()));
|
|
|
+ File file4 = new File(String.format("C:/tmp/%sdata.xlsx", config4.getName()));
|
|
|
FileInputStream in4 = new FileInputStream(file4);
|
|
|
item4.importExcelRecord(in4);
|
|
|
|
|
|
@@ -100,10 +105,26 @@ public class PVTest {
|
|
|
vo.getItem().add(item4);
|
|
|
|
|
|
final Workbook workbook = vo.exportExcelReport();
|
|
|
- FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx",vo.getName()));
|
|
|
+ FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx", vo.getName()));
|
|
|
workbook.write(fos);
|
|
|
fos.close();
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testChart() throws Exception {
|
|
|
+ FileInputStream fis = new FileInputStream("C:/tmp/TEST.xlsx");
|
|
|
+ XSSFWorkbook wb = new XSSFWorkbook(fis);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+ XSSFDrawing drawing = sheet.getDrawingPatriarch();
|
|
|
+ List<XSSFChart> charts = drawing.getCharts();
|
|
|
+ for (int i = 0; i < charts.size(); i++) {
|
|
|
+ XSSFChart chart = charts.get(i);
|
|
|
+ CTChart ctChart = chart.getCTChart();
|
|
|
+ System.out.println(ctChart);
|
|
|
+ }
|
|
|
+ fis.close();
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
}
|