diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/MainFrm.cs b/MainFrm.cs
index 4588ce5..88ffa8f 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -7493,6 +7493,7 @@
table.Columns.Add("侵入长度/m");
table.Columns.Add("侵入管线长度");
table.Columns.Add("侵入附属物个数");
+
for (int i = 0; i < dt.Count; i++)
{
DataRow row = table.NewRow();
@@ -7504,6 +7505,7 @@
row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
table.Rows.Add(row);
}
+
dataGridView.DataSource = table;
redSH = true;
panelOfTable.Visible = true;
@@ -7519,7 +7521,7 @@
///
private void toolStripDropDownButton3_Click(object sender, EventArgs e)
{
- if (dataGridViewX1.Rows.Count != 0)
+ if (dataGridViewX1.Rows.Count == 0)
{
MessageBox.Show("表格内容为空!", "提示");
return;
@@ -7533,7 +7535,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
+ ExpEXCEL.ExpToExcelWithManySheet(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/MainFrm.cs b/MainFrm.cs
index 4588ce5..88ffa8f 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -7493,6 +7493,7 @@
table.Columns.Add("侵入长度/m");
table.Columns.Add("侵入管线长度");
table.Columns.Add("侵入附属物个数");
+
for (int i = 0; i < dt.Count; i++)
{
DataRow row = table.NewRow();
@@ -7504,6 +7505,7 @@
row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
table.Rows.Add(row);
}
+
dataGridView.DataSource = table;
redSH = true;
panelOfTable.Visible = true;
@@ -7519,7 +7521,7 @@
///
private void toolStripDropDownButton3_Click(object sender, EventArgs e)
{
- if (dataGridViewX1.Rows.Count != 0)
+ if (dataGridViewX1.Rows.Count == 0)
{
MessageBox.Show("表格内容为空!", "提示");
return;
@@ -7533,7 +7535,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
+ ExpEXCEL.ExpToExcelWithManySheet(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 1970d6a..51110e6 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -102,7 +102,7 @@
redLineResult.Length = GetLength(lineFeatsInOrCrossPolygon, lineFeatsInPolygon,
redLineFeaturePolygon);
-
+ if (redLineResult.Length == 0) continue;
/* GSOFeatures combPipeLineFeat = ConnectLine(lineFeatsInOrCrossPolygon);
double area = 0;
for (int k = 0; k < combPipeLineFeat.Length; k++)
@@ -111,9 +111,7 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
- if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
- redLineResult.PointFeaturesInRedLine.Length == 0)
- continue;
+
results.Add(redLineResult);
}
}
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/MainFrm.cs b/MainFrm.cs
index 4588ce5..88ffa8f 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -7493,6 +7493,7 @@
table.Columns.Add("侵入长度/m");
table.Columns.Add("侵入管线长度");
table.Columns.Add("侵入附属物个数");
+
for (int i = 0; i < dt.Count; i++)
{
DataRow row = table.NewRow();
@@ -7504,6 +7505,7 @@
row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
table.Rows.Add(row);
}
+
dataGridView.DataSource = table;
redSH = true;
panelOfTable.Visible = true;
@@ -7519,7 +7521,7 @@
///
private void toolStripDropDownButton3_Click(object sender, EventArgs e)
{
- if (dataGridViewX1.Rows.Count != 0)
+ if (dataGridViewX1.Rows.Count == 0)
{
MessageBox.Show("表格内容为空!", "提示");
return;
@@ -7533,7 +7535,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
+ ExpEXCEL.ExpToExcelWithManySheet(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 1970d6a..51110e6 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -102,7 +102,7 @@
redLineResult.Length = GetLength(lineFeatsInOrCrossPolygon, lineFeatsInPolygon,
redLineFeaturePolygon);
-
+ if (redLineResult.Length == 0) continue;
/* GSOFeatures combPipeLineFeat = ConnectLine(lineFeatsInOrCrossPolygon);
double area = 0;
for (int k = 0; k < combPipeLineFeat.Length; k++)
@@ -111,9 +111,7 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
- if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
- redLineResult.PointFeaturesInRedLine.Length == 0)
- continue;
+
results.Add(redLineResult);
}
}
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index c6882a1..541e0a1 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/MainFrm.cs b/MainFrm.cs
index 4588ce5..88ffa8f 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -7493,6 +7493,7 @@
table.Columns.Add("侵入长度/m");
table.Columns.Add("侵入管线长度");
table.Columns.Add("侵入附属物个数");
+
for (int i = 0; i < dt.Count; i++)
{
DataRow row = table.NewRow();
@@ -7504,6 +7505,7 @@
row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
table.Rows.Add(row);
}
+
dataGridView.DataSource = table;
redSH = true;
panelOfTable.Visible = true;
@@ -7519,7 +7521,7 @@
///
private void toolStripDropDownButton3_Click(object sender, EventArgs e)
{
- if (dataGridViewX1.Rows.Count != 0)
+ if (dataGridViewX1.Rows.Count == 0)
{
MessageBox.Show("表格内容为空!", "提示");
return;
@@ -7533,7 +7535,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
+ ExpEXCEL.ExpToExcelWithManySheet(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 1970d6a..51110e6 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -102,7 +102,7 @@
redLineResult.Length = GetLength(lineFeatsInOrCrossPolygon, lineFeatsInPolygon,
redLineFeaturePolygon);
-
+ if (redLineResult.Length == 0) continue;
/* GSOFeatures combPipeLineFeat = ConnectLine(lineFeatsInOrCrossPolygon);
double area = 0;
for (int k = 0; k < combPipeLineFeat.Length; k++)
@@ -111,9 +111,7 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
- if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
- redLineResult.PointFeaturesInRedLine.Length == 0)
- continue;
+
results.Add(redLineResult);
}
}
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index c6882a1..541e0a1 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb
index 4c46ebd..79bcecb 100644
--- a/bin/x86/Debug/Cyberpipe.pdb
+++ b/bin/x86/Debug/Cyberpipe.pdb
Binary files differ
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index 67d706b..a02c640 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ExpEXCEL.cs b/ExpEXCEL.cs
index aadbd3f..3b703e3 100644
--- a/ExpEXCEL.cs
+++ b/ExpEXCEL.cs
@@ -24,51 +24,15 @@
{
//创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
Workbook workbook = workbooks.Add(miss);
Worksheet sheet = workbook.Worksheets[1];
- sheet.Name = str;
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, str);
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
- sheetStype(sheet, dt);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
-
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
///
@@ -76,87 +40,26 @@
///
public static void ExpToExcel(DataGridView dt1, DataGridView dt, string strSaveFile)
{
- //创建一个EXCEL应用程序
Application excel = new Application();
- //是否显示导出过程(显示创建后的EXCEL)
excel.Visible = false;
excel.Workbooks.Add(true);
- //定义缺省值
Missing miss = Missing.Value;
- //创建一个新的工作簿
Workbooks workbooks = excel.Workbooks;
-
Workbook workbook = workbooks.Add(miss);
-
Worksheet sheet = workbook.Worksheets[1];
-
Worksheet sheet1;
if (workbook.Worksheets.Count == 1)
- {
- sheet1 = (Worksheet)workbook.Worksheets.Add(miss, workbook.ActiveSheet);
- }
- else {
+ sheet1 = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+ else
sheet1 = workbook.Worksheets[2];
- }
-
- sheet.Name = "垂直距离";
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
- }
+ AddDataGridViewDataToSheet(sheet, dt, "垂直距离");
- //填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();
- }
- }
+ AddDataGridViewDataToSheet(sheet1, dt1, "水平距离");
- sheetStype(sheet, dt);
-
- sheet1.Name = "水平距离";
- for (int i = 0; i < dt1.Columns.Count; i++)
- {
- sheet1.Cells[1, i + 1] = dt1.Columns[i].HeaderText;
- }
-
- //填充数据
- for (int i = 0; i < dt1.Rows.Count; i++)//所要添加的行数
- {
- for (int j = 0; j < dt1.Columns.Count; j++)//每行的列数
- {
- //将数据填充到对应的单元格中
- sheet1.Cells[i + 2, j + 1] = dt1.Rows[i].Cells[j].Value.ToString();
- }
- }
-
- sheetStype(sheet, dt1);
-
- //保存文件
- string strSaveFile2 = strSaveFile;
- if (File.Exists(strSaveFile2))
- {
- int z = 1;
- do
- {
- strSaveFile2 = Path.Combine(Path.GetDirectoryName(strSaveFile) + "\\" + Path.GetFileNameWithoutExtension(strSaveFile) + z + ".xlsx");
- z++;
- } while (File.Exists(strSaveFile2));
- }
-
- sheet.SaveAs(strSaveFile2, miss, miss, miss, miss, miss, XlSaveAsAccessMode.xlNoChange, miss, miss, miss);
- //关闭表格
- workbook.Close(false, miss, miss);
- workbooks.Close();
- //释放资源
- excel.Quit();
- KillProcess(excel);
+ SaveExcel(strSaveFile, excel, workbook, workbooks, miss);
}
static List sheetNameList = new List();
@@ -165,7 +68,7 @@
///
///
///
- public static void ExpToExcelContain(DataGridView dt, string strSaveFile, string str)
+ public static void ExpToExcelWithManySheet(DataGridView dt, string strSaveFile, string str)
{
if (dt.Rows.Count == 0) return;
sheetNameList.Clear();
@@ -177,55 +80,66 @@
Missing miss = Missing.Value;//定义缺省值
Workbooks workbooks = excel.Workbooks;//创建一个新的工作簿
Workbook workbook = workbooks.Add(miss);
- Worksheet sheet = null;
+ Worksheet sheet = workbook.Worksheets[1];
+
+ AddDataGridViewDataToSheet(sheet, dt, str);
+
+ for (int sheetCount = 0; sheetCount < dt.Rows.Count; sheetCount++)
+ {
+ if (workbook.Worksheets.Count >(sheetCount+1))
+ sheet = workbook.Worksheets[sheetCount + 2];
+ else
+ sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
+
+ DataTable dataTable = new DataTable();
+ dataTable.Columns.Add("图层类型");
+ 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);
+ }
+
+ static void AddDataGridViewDataToSheet(Worksheet sheet, DataGridView dt,string str)
+ {
sheet.Name = str;
for (int i = 0; i < dt.Columns.Count; i++)
{
sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
}
//填充数据
- for (int i = 0; i < dt.Rows.Count; i++)//所要添加的行数
+ for (int i = 0; i < dt.Rows.Count; i++) //所要添加的行数
{
- for (int j = 0; j < dt.Columns.Count; j++)//每行的列数
+ for (int j = 0; j < dt.Columns.Count; j++) //每行的列数
{
- sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString();//将数据填充到对应的单元格中
+ sheet.Cells[i + 2, j + 1] = dt.Rows[i].Cells[j].Value.ToString(); //将数据填充到对应的单元格中
}
}
- sheetStype(sheet, dt);
+ SheetStype(sheet, dt);
+ }
- for (int sheetCount = 0; sheetCount <= dt.Rows.Count; sheetCount++)
+ static void AddDataTableDataToSheet(Worksheet sheet,string layerName,string redLineName,int sheetCount,DataTable dataTable)
+ {
+ for (int i = 0; i < RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine.Length; i++)
{
- if (workbook.Worksheets.Count > sheetCount)
- sheet = workbook.Worksheets[sheetCount + 1];
- else
- sheet = (Worksheet) workbook.Worksheets.Add(miss, workbook.ActiveSheet);
-
- for (int i = 0; i < dt.Columns.Count; i++)
+ if (RedLineAnalysisTool.redLineResultList[sheetCount].LineFeaturesInRedLine[i].Dataset.Caption ==
+ layerName && RedLineAnalysisTool.redLineResultList[sheetCount].RedLineName == redLineName)
{
- sheet.Cells[1, i + 1] = dt.Columns[i].HeaderText;
+ 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);
}
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("图层类型");
- dataTable.Columns.Add("编号");
-
- layerName = dt.Rows[sheetCount - 1].Cells["管线类型"].Value.ToString();
- redLineName = dt.Rows[sheetCount - 1].Cells["红线编号"].Value.ToString();
-
- 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++)
+ for (int j = 0; j < RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine.Length; j++)
{
GSOFeatures feats = RedLineAnalysisTool.redLineResultList[sheetCount].PointFeaturesInRedLine;
if (feats[0].Dataset.Caption.Contains(layerName))
@@ -240,36 +154,36 @@
}
}
}
-
- if (!sheetNameList.Contains(layerName))
- {
- sheet.Name = layerName;
- sheetNameList.Add(layerName);
- }
- else
- {
- sheet.Name = layerName + "1";
- sheetNameList.Add(layerName + "1");
- }
-
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
- }
-
- //填充数据
- for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
- {
- for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
- {
- sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
- }
- }
-
- sheetStype(sheet, dataTable);
-
+ }
+ if (!sheetNameList.Contains(layerName))
+ {
+ sheet.Name = layerName;
+ sheetNameList.Add(layerName);
+ }
+ else
+ {
+ sheet.Name = layerName + "1";
+ sheetNameList.Add(layerName + "1");
}
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ sheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
+ }
+ //填充数据
+ for (int i = 0; i < dataTable.Rows.Count; i++) //所要添加的行数
+ {
+ for (int j = 0; j < dataTable.Columns.Count; j++) //每行的列数
+ {
+ sheet.Cells[i + 2, j + 1] = dataTable.Rows[i][j].ToString(); //将数据填充到对应的单元格中
+ }
+ }
+
+ SheetStype(sheet, dataTable);
+ }
+
+ static void SaveExcel(string strSaveFile,Application excel, Workbook workbook, Workbooks workbooks, Missing miss)
+ {
if (File.Exists(strSaveFile))
{
int z = 1;
@@ -285,44 +199,22 @@
excel.Quit();//释放资源
}
- static void sheetStype(Worksheet sheet,DataGridView dataTable)
+ static void SheetStype(Worksheet sheet,DataGridView dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- static void sheetStype(Worksheet sheet, DataTable dataTable)
+ static void SheetStype(Worksheet sheet, DataTable dataTable)
{
- Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, dataTable.Columns.Count]];//设置列标题的背景颜色
int rowscount = dataTable.Rows.Count;//重新选择单元格范围
int columncount = dataTable.Columns.Count;
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount, 1]];//将范围重新确定为每一行的第一个单元格
- er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
+ Range er = sheet.Range[sheet.Cells[1, 1], sheet.Cells[rowscount + 1, columncount + 1]];//选中EXCEL所有表格
er.EntireColumn.AutoFit();//让EXCEL中的所有单元格的列宽碎文字的长短自动调整
er.HorizontalAlignment = XlHAlign.xlHAlignCenter;// 让EXCEL的文本水平居中方式
}
- ///
- /// 杀死进程
- ///
- ///
- private static void KillProcess(Application app)
- {
- IntPtr t = new IntPtr(app.Hwnd);
- int k = 0;
- GetWindowThreadProcessId(t, out k);
- Process p = Process.GetProcessById(k);
- p.Kill();
- }
-
- [DllImport("User32.dll", CharSet = CharSet.Auto)]
- public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
-
-
-
}
}
diff --git a/FrmAnalysisGuiHuaResult.cs b/FrmAnalysisGuiHuaResult.cs
index 6d9c10c..65761d5 100644
--- a/FrmAnalysisGuiHuaResult.cs
+++ b/FrmAnalysisGuiHuaResult.cs
@@ -37,7 +37,8 @@
&& RedLineAnalysisTool.redLineResultList[i].RedLineName == redLineName)
{
addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].LineFeaturesInRedLine);
- addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
+ if (RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine != null)
+ addDataToDataTable(dt, RedLineAnalysisTool.redLineResultList[i].PointFeaturesInRedLine);
}
}
@@ -75,9 +76,6 @@
globleControl1.Globe.JumpToFeature(feature, 10);
}
- ///
- /// 高亮显示
- ///
public void highlight()
{
timer1.Start();
diff --git a/MainFrm.cs b/MainFrm.cs
index 4588ce5..88ffa8f 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -7493,6 +7493,7 @@
table.Columns.Add("侵入长度/m");
table.Columns.Add("侵入管线长度");
table.Columns.Add("侵入附属物个数");
+
for (int i = 0; i < dt.Count; i++)
{
DataRow row = table.NewRow();
@@ -7504,6 +7505,7 @@
row[5] = dt[i].PointFeaturesInRedLine == null ? 0 : dt[i].PointFeaturesInRedLine.Length;
table.Rows.Add(row);
}
+
dataGridView.DataSource = table;
redSH = true;
panelOfTable.Visible = true;
@@ -7519,7 +7521,7 @@
///
private void toolStripDropDownButton3_Click(object sender, EventArgs e)
{
- if (dataGridViewX1.Rows.Count != 0)
+ if (dataGridViewX1.Rows.Count == 0)
{
MessageBox.Show("表格内容为空!", "提示");
return;
@@ -7533,7 +7535,7 @@
strSaveFile = savefiledialog.FileName;
else return;
- ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核");
+ ExpEXCEL.ExpToExcelWithManySheet(dataGridViewX1, strSaveFile, "红线审核");
MessageBox.Show("导出成功!");
}
diff --git a/RedLineAnalysisTool.cs b/RedLineAnalysisTool.cs
index 1970d6a..51110e6 100644
--- a/RedLineAnalysisTool.cs
+++ b/RedLineAnalysisTool.cs
@@ -102,7 +102,7 @@
redLineResult.Length = GetLength(lineFeatsInOrCrossPolygon, lineFeatsInPolygon,
redLineFeaturePolygon);
-
+ if (redLineResult.Length == 0) continue;
/* GSOFeatures combPipeLineFeat = ConnectLine(lineFeatsInOrCrossPolygon);
double area = 0;
for (int k = 0; k < combPipeLineFeat.Length; k++)
@@ -111,9 +111,7 @@
}
redLineResult.MinArea = area;*/
redLineResult.MinArea = 0;
- if (redLineResult.LineFeaturesInRedLine.Length == 0 &&
- redLineResult.PointFeaturesInRedLine.Length == 0)
- continue;
+
results.Add(redLineResult);
}
}
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index c6882a1..541e0a1 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb
index 4c46ebd..79bcecb 100644
--- a/bin/x86/Debug/Cyberpipe.pdb
+++ b/bin/x86/Debug/Cyberpipe.pdb
Binary files differ
diff --git a/bin/x86/Debug/glVersion.txt b/bin/x86/Debug/glVersion.txt
index 1fc46d0..06a7613 100644
--- a/bin/x86/Debug/glVersion.txt
+++ b/bin/x86/Debug/glVersion.txt
Binary files differ