Shuxia Ning
2024-10-15 a8e54743e599fa42d627cc97ab1468937e719c04
WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/02-chart/Perform2dExportHelper.cs
@@ -12,11 +12,11 @@
        /// <summary>
        /// 导出
        /// </summary> 
        public static void ExportXLS(Yw.Geometry.CubicSpline2d cubic_spline_qh, Yw.Geometry.CubicSpline2d cubic_spline_qe, Yw.Geometry.CubicSpline2d cubic_spline_qp, int fitPointNum = 15)
        public static void ExportXLS(Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp, int fitPointNum = 15)
        {
            try
            {
                if (cubic_spline_qh == null)
                if (qh == null)
                    return;
                var dlg = new SaveFileDialog();
@@ -35,8 +35,8 @@
                //均匀插值点,计算点坐标
                double minQ = cubic_spline_qh.MinX;
                double maxQ = cubic_spline_qh.MaxX;
                double minQ = qh.MinX;
                double maxQ = qh.MaxX;
                double space = (maxQ - minQ) / (fitPointNum - 1);
                double Q = minQ;
                double H, E, P;
@@ -48,32 +48,32 @@
                    row.CreateCell(col).SetCellValue(Trans(Q));
                    col++;
                    H = cubic_spline_qh.GetPointY(Q);
                    H = qh.GetPointY(Q);
                    row.CreateCell(col).SetCellValue(Trans(H));
                    col++;
                    if (cubic_spline_qe != null && Q <= cubic_spline_qe.MaxX && Q >= cubic_spline_qe.MinX)
                    if (qe != null && Q <= qe.MaxX && Q >= qe.MinX)
                    {
                        if (Q < 0.1)
                            E = 0;
                        else
                            E = cubic_spline_qe.GetPointY(Q);
                            E = qe.GetPointY(Q);
                        row.CreateCell(col).SetCellValue(Trans(E));
                        col++;
                    }
                    if (cubic_spline_qp != null && Q <= cubic_spline_qp.MaxX && Q >= cubic_spline_qp.MinX)
                    if (qp != null && Q <= qp.MaxX && Q >= qp.MinX)
                    {
                        P = cubic_spline_qp.GetPointY(Q);
                        P = qp.GetPointY(Q);
                        row.CreateCell(col).SetCellValue(Trans(P));
                        col++;
                    }
                    Q = Q + space;
                    if (Q > cubic_spline_qh.MaxX * 0.9999)
                        Q = cubic_spline_qh.MaxX * 0.9999;
                    if (Q > qh.MaxX * 0.9999)
                        Q = qh.MaxX * 0.9999;
                }
                //强制Excel在打开时重新计算所有公式
@@ -94,11 +94,11 @@
        /// <summary>
        /// 导出定义点
        /// </summary> 
        public static void ExportDefinePoints(List<Yw.Geometry.Point2d> cubic_spline_qh, List<Yw.Geometry.Point2d> cubic_spline_qe, List<Yw.Geometry.Point2d> cubic_spline_qp, int fitPointNum = 15)
        public static void ExportDefinePoints(List<Yw.Geometry.Point2d> qh, List<Yw.Geometry.Point2d> qe, List<Yw.Geometry.Point2d> qp, int fitPointNum = 15)
        {
            try
            {
                if (cubic_spline_qh == null)
                if (qh == null)
                    return;
                var dlg = new SaveFileDialog();
@@ -116,53 +116,53 @@
                rowTile.CreateCell(2).SetCellValue("效率");
                rowTile.CreateCell(3).SetCellValue("功率");
                List<Yw.Geometry.Point2d> pt_qh_list = null, pt_qe_list = null, pt_qp_list = null;
                List<Yw.Geometry.Point2d> qh_pt_list = null, qe_pt_list = null, qp_pt_list = null;
                pt_qh_list = cubic_spline_qh;
                qh_pt_list = qh;
                if (pt_qh_list == null || pt_qh_list.Count < 4)
                if (qh_pt_list == null || qh_pt_list.Count < 4)
                    return;
                pt_qe_list = cubic_spline_qe;
                pt_qp_list = cubic_spline_qp;
                qe_pt_list = qe;
                qp_pt_list = qp;
                //均匀插值点,计算点坐标
                double minQ = cubic_spline_qh.Min()?.X ?? 0;
                double maxQ = cubic_spline_qh.Max()?.X ?? 0;
                double minQ = qh.Min()?.X ?? 0;
                double maxQ = qh.Max()?.X ?? 0;
                double space = (maxQ - minQ) / (fitPointNum - 1);
                double Q = 0;
                double H, E = 0, P = 0;
                int rowIndex = 1;
                foreach (var pointQH in pt_qh_list)
                foreach (var pointQH in qh_pt_list)
                {
                    Q = pointQH.X;
                    H = pointQH.Y;
                    if (pt_qe_list != null && pt_qe_list.Count > 0)
                    if (qe_pt_list != null && qe_pt_list.Count > 0)
                    {
                        var pointQE = pt_qe_list.Find(x => x.X == Q);
                        var pointQE = qe_pt_list.Find(x => x.X == Q);
                        if (pointQE != null)
                        {
                            E = pointQE.Y;
                        }
                        else
                        {
                            E = pt_qe_list.GetPointIndexByX(Q);
                            E = qe_pt_list.GetPointIndexByX(Q);
                        }
                    }
                    if (pt_qp_list != null && pt_qp_list.Count > 0)
                    if (qp_pt_list != null && qp_pt_list.Count > 0)
                    {
                        var pointQP = pt_qp_list.Find(x => x.X == Q);
                        var pointQP = qp_pt_list.Find(x => x.X == Q);
                        if (pointQP != null)
                        {
                            P = pointQP.Y;
                        }
                        else
                        {
                            P = cubic_spline_qp.GetPointIndexByX(Q);
                            P = qp.GetPointIndexByX(Q);
                        }
                    }