فهرست منبع

execl 谱图 临时提交

CXS 3 سال پیش
والد
کامیت
5647b11b00

+ 44 - 35
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -1958,32 +1958,40 @@ namespace OTSIncAReportGrids
 
                 ISheet sheet3;
                 sheet3 = workbook.CreateSheet("Peak spectrum");//创建工作表
-                sheet3.SetColumnWidth(0, 100 * 256);//图像列宽
-                ////插入表头
-                //row = sheet3.CreateRow(1);
-                //row.Height = 30 * 20;
-                //cell = row.CreateCell(0);
-                //cell.CellStyle = cellStyle;
-                //cell.SetCellValue("rowid");
-
-                //cell = row.CreateCell(1);
-                //cell.CellStyle = cellStyle;
-                //cell.SetCellValue("PeakSpectrum");
-                //for (int j = 0; j < particles.Rows.Count; j++)
+                sheet3.SetColumnWidth(1, 200 * 256);//图像列宽
+                //插入表头
+                row = sheet3.CreateRow(1);
+                row.Height = 30 * 20;
+                cell = row.CreateCell(0);
+                cell.CellStyle = cellStyle;
+                cell.SetCellValue("rowid");
+
+                cell = row.CreateCell(1);
+                cell.CellStyle = cellStyle;
+                cell.SetCellValue("PeakSpectrum");
+                //for (int j = 0; j < 1; j++)//particles.Rows.Count
                 //{
-                    row = sheet3.CreateRow(1);
-                    row.Height = 60 * 20;
-                    cell = row.CreateCell(0);
-                    cell.CellStyle = cellStyle;
-                    //cell.SetCellValue(1);
-                    cell = row.CreateCell(1);
-                    cell = row.CreateCell(2);
-                    IDrawing drawing = sheet3.CreateDrawingPatriarch();
-                    //锚点
-                    IClientAnchor anchor3 = drawing.CreateAnchor(0, 0, 0, 0, 0, 0, 2, 2);//XSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2);参数说明:dx1 dy1 起始单元格中的x,y坐标.dx2 dy2 结束单元格中的x,y坐标col1, row1 指定起始的单元格,下标从0开始col2, row2 指定结束的单元格,下标从0开始
-                    CreateChart(drawing, sheet2, anchor3, "title1");
+                //    row = sheet3.CreateRow(j+2);
+                //    row.Height = 120 * 20;
+                //    cell = row.CreateCell(0);
+                //    cell.CellStyle = cellStyle;
+                //    cell.SetCellValue(j+1);
+                //    cell = row.CreateCell(1);
+                //    IDrawing drawing = sheet3.CreateDrawingPatriarch();
+                //    //锚点
+                //    IClientAnchor anchor3 = drawing.CreateAnchor(0, 0, 0, 0, j+2, 1, j+2, 1);//XSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2);参数说明:dx1 dy1 起始单元格中的x,y坐标.dx2 dy2 结束单元格中的x,y坐标col1, row1 指定起始的单元格,下标从0开始col2, row2 指定结束的单元格,下标从0开始
+                //    CreateChart(drawing, sheet2, anchor3, j+2);
                 //}
-
+                row = sheet3.CreateRow(2);
+                row.Height = 120 * 20;
+                cell = row.CreateCell(0);
+                cell.CellStyle = cellStyle;
+                cell.SetCellValue(1);
+                cell = row.CreateCell(1);
+                IDrawing drawing = sheet3.CreateDrawingPatriarch();
+                //锚点
+                IClientAnchor anchor3 = drawing.CreateAnchor(0, 0, 0, 0, 0, 0, 1, 1);//XSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2);参数说明:dx1 dy1 起始单元格中的x,y坐标.dx2 dy2 结束单元格中的x,y坐标col1, row1 指定起始的单元格,下标从0开始col2, row2 指定结束的单元格,下标从0开始
+                CreateChart(drawing, sheet2, anchor3,2);
 
                 //完成后,对Excel进行保存
                 FileStream file = new FileStream(sfd.FileName, FileMode.Create);
@@ -2003,23 +2011,25 @@ namespace OTSIncAReportGrids
             }
         }
 
-        void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, string serie1)
+        void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, int rowid)
         {
             var chart = drawing.CreateChart(anchor) as XSSFChart;
             // 创建图形注释的位置
             //var legend = chart.GetOrCreateLegend();
             //legend.Position = LegendPosition.Top;
-            
 
-            //图表
-            var data = chart.GetChartDataFactory().CreateLineChartData<double, double>(); //折线图散点图
 
-            IChartAxis bottomAxis = chart.GetChartAxisFactory().CreateCategoryAxis(AxisPosition.Bottom);
-            IValueAxis leftAxis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.Left);
-            leftAxis.SetCrosses(AxisCrosses.AutoZero);
+            //图表
+            var data = chart.ChartDataFactory.CreateLineChartData<double, double>(); //折线图
 
+            IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom);
+            
+            IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left);
+            leftAxis.Crosses=AxisCrosses.AutoZero;
+            leftAxis.IsVisible = true;
+            bottomAxis.IsVisible = true;
             //数据源
-            //IChartDataSource<double> xs = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(1, 1, 1, 2001));
+            IChartDataSource<double> ys = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(rowid, rowid, 1, 2001));
 
             Double[] doubles = new Double[2000];
             for (int i = 0; i < 2000; i++)
@@ -2027,11 +2037,10 @@ namespace OTSIncAReportGrids
                 doubles[i] = i;
             }
             IChartDataSource<double> xs = DataSources.FromArray(doubles);
-            IChartDataSource<double> ys = DataSources.FromArray(doubles);
+            //IChartDataSource<double> ys = DataSources.FromArray(doubles);
 
             //数据系列
-            var s1 = data.AddSerie(xs, ys);
-            s1.SetTitle(serie1);
+            var s1 = data.AddSeries(xs, ys);
 
             // 开始绘制折线图
             chart.Plot(data, bottomAxis, leftAxis);

+ 1 - 1
OTSIncAReportApp/1-UI/OTSTemplateDesigner/Export_NPOI_Excel.cs

@@ -163,7 +163,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
 
             IClientAnchor anchor = sheet.GetRow(m_Excel_Row_CurrentNumber + row).GetCell(cell).Sheet.Workbook.GetCreationHelper().CreateClientAnchor();
 
-            anchor.AnchorType = (int)AnchorType.MoveDontResize;
+            anchor.AnchorType = AnchorType.MoveDontResize;
             int dx1 = 200;
             int dy1 = 50;
             //在单元格上的位置,不能居中就要这样弄了

+ 4 - 0
OTSIncAReportApp/App.config

@@ -40,6 +40,10 @@
         <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
         <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
       </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
+      </dependentAssembly>
     </assemblyBinding>
   </runtime>
   <entityFramework>

+ 13 - 19
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -161,6 +161,9 @@
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="BouncyCastle.Crypto, Version=1.8.9.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
+      <HintPath>..\packages\Portable.BouncyCastle.1.8.9\lib\net40\BouncyCastle.Crypto.dll</HintPath>
+    </Reference>
     <Reference Include="CefSharp, Version=51.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\Bin\x64\Debug\CefSharp.dll</HintPath>
@@ -179,9 +182,8 @@
     <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
     </Reference>
-    <Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Bin\x64\Debug\ICSharpCode.SharpZipLib.dll</HintPath>
+    <Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
+      <HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
     </Reference>
     <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -206,25 +208,17 @@
     <Reference Include="NLog">
       <HintPath>..\Bin\x64\Debug\NLog.dll</HintPath>
     </Reference>
-    <Reference Include="NPOI, Version=2.1.3.1, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\OpenDll\WordApiDll\NPOI.dll</HintPath>
-      <Private>False</Private>
+    <Reference Include="NPOI, Version=2.5.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.2.5.6\lib\net45\NPOI.dll</HintPath>
     </Reference>
-    <Reference Include="NPOI.OOXML, Version=2.1.3.1, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\OpenDll\WordApiDll\NPOI.OOXML.dll</HintPath>
-      <Private>False</Private>
+    <Reference Include="NPOI.OOXML, Version=2.5.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.2.5.6\lib\net45\NPOI.OOXML.dll</HintPath>
     </Reference>
-    <Reference Include="NPOI.OpenXml4Net, Version=2.1.3.1, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\OpenDll\WordApiDll\NPOI.OpenXml4Net.dll</HintPath>
-      <Private>False</Private>
+    <Reference Include="NPOI.OpenXml4Net, Version=2.5.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.2.5.6\lib\net45\NPOI.OpenXml4Net.dll</HintPath>
     </Reference>
-    <Reference Include="NPOI.OpenXmlFormats, Version=2.1.3.1, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\OpenDll\WordApiDll\NPOI.OpenXmlFormats.dll</HintPath>
-      <Private>False</Private>
+    <Reference Include="NPOI.OpenXmlFormats, Version=2.5.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
+      <HintPath>..\packages\NPOI.2.5.6\lib\net45\NPOI.OpenXmlFormats.dll</HintPath>
     </Reference>
     <Reference Include="office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>

+ 3 - 0
OTSIncAReportApp/packages.config

@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
+  <package id="NPOI" version="2.5.6" targetFramework="net462" />
   <package id="OpenCvSharp4" version="4.5.5.20211231" targetFramework="net462" />
   <package id="OpenCvSharp4.runtime.win" version="4.5.5.20211231" targetFramework="net462" />
   <package id="OpenCvSharp4.Windows" version="4.5.5.20211231" targetFramework="net462" />
+  <package id="Portable.BouncyCastle" version="1.8.9" targetFramework="net462" />
+  <package id="SharpZipLib" version="1.3.3" targetFramework="net462" />
   <package id="System.Buffers" version="4.5.1" targetFramework="net462" />
   <package id="System.Collections" version="4.3.0" targetFramework="net472" />
   <package id="System.Data.SQLite.EF6" version="1.0.115.0" targetFramework="net472" />