diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs index d0dd880..e99c837 100644 --- a/ExpEXCEL.cs +++ b/ExpEXCEL.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using GeoScene.Data; using Microsoft.Office.Interop.Excel; +using Org.BouncyCastle.Bcpg.Sig; using Application = Microsoft.Office.Interop.Excel.Application; using DataTable = System.Data.DataTable; @@ -70,6 +71,7 @@ /// public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str) { + Debug.WriteLine("ExpToExcelWithManySheet"); if (dt.Rows.Count == 0) return; sheetNameList.Clear(); string layerName = ""; @@ -83,6 +85,7 @@ Worksheet sheet = workbook.Worksheets[1]; + // 加入数据 (红线审核sheet) AddDataGridViewDataToSheet(sheet, dt, str); for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++) @@ -97,15 +100,17 @@ dataTable.Columns.Add("编号"); layerName = dt.Rows[sheetCount].Cells["管线类型"].Value.ToString(); redLineName = dt.Rows[sheetCount].Cells["红线编号"].Value.ToString(); - + // // 加入数据 (污水管线、雨水管线等) AddDataTableDataToSheet(sheet, layerName, redLineName, sheetCount, dataTable); } SaveExcel(strSaveFile, excel, workbook, workbooks, miss); + Debug.WriteLine("退出ExpToExcelWithManySheet"); } static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str) { + Debug.WriteLine("AddDataGridViewDataToSheet"); sheet.Name = str; for (int i = 0; i < dt.Columns.Count; i++) { @@ -120,41 +125,71 @@ } } SheetStype(sheet, dt); + Debug.WriteLine("退出AddDataGridViewDataToSheet"); } static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable) { - for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++) + + for (int i = 0; i < RedLineAnalysisTool.redLineResultList.Count; i++) { - if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == - layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName) + if (RedLineAnalysisTool.redLineResultList[i].LayerName == layerName + && RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName) { - DataRow row = dataTable.NewRow(); - row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption; - row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name; - dataTable.Rows.Add(row); - } - } - if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine != null) - { - if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0) - { - for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++) + for (int m = 0; m < RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine.Length; m++) { - GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine; - if (feats[0].Dataset.Caption.Contains(layerName)) + DataRow row = dataTable.NewRow(); + row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption; + row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name; + dataTable.Rows.Add(row); + } + if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null) + { + for (int m = 0; m < RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine.Length; m++) { - for (int n = 0; n < feats.Length; n++) - { - DataRow pointRow = dataTable.NewRow(); - pointRow[0] = feats[n].Dataset.Caption; - pointRow[1] = feats[n].GetFieldAsString("编号"); - dataTable.Rows.Add(pointRow); - } + DataRow row = dataTable.NewRow(); + row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine[i].Dataset.Caption; + row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine[i].Name; + dataTable.Rows.Add(row); } } } } + + + //// 红线 + //for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++) + //{ + // if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption == + // layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName) + // { + // DataRow row = dataTable.NewRow(); + // row[0] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption; + // row[1] = RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Name; + // dataTable.Rows.Add(row); + // } + //} + //// 红线附属物 + //if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine != null) + //{ + // if (RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length > 0) + // { + // for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++) + // { + // GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine; + // if (feats[0].Dataset.Caption.Contains(layerName)) + // { + // for (int n = 0; n < feats.Length; n++) + // { + // DataRow pointRow = dataTable.NewRow(); + // pointRow[0] = feats[n].Dataset.Caption; + // pointRow[1] = feats[n].GetFieldAsString("编号"); + // dataTable.Rows.Add(pointRow); + // } + // } + // } + // } + //} if (!sheetNameList.Contains(layerName)) { sheet.Name = layerName;