C#下面调用 Excel 另存代码
2007-05-01 12:35
471 查看
google_ad_client = "pub-2048279401139630";google_ad_slot = "8856771542";google_ad_width = 728;google_ad_height = 90;document.write("");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private void btnSaveAsData_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel.Application xlsApp = new Excel.Application();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel._Workbook xlsBook = xlsApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel._Worksheet xlsSheet = (Excel._Worksheet)xlsBook.Worksheets[1];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Activate();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Caption = lblDMMC.Text + "断面实测成果表 - 另存为 ";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataTable myDT1, myDT2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1 = datatable(a,a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT2 = datatable(a,a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double minGaocheng = 0;//Get_min(a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
string[] strColName = new string[] ...{ "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "" };
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int intCols = strColName.Length - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int intRows = myDT1.Rows.Count;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int[] intRows1 = new int[myDT1.Rows.Count];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int[] intcols1 = new int[myDT1.Columns.Count];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int minrow = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int mincol = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int zhanyonghang = 3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[2, 7] = lblDMMC.Text + "断面实测成果表";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang+2, intCols + 1] = "制";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 3, intCols + 1] = "表";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 4, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 7, intCols + 1] = "一";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 8, intCols + 1] = "校";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 9, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 12, intCols + 1] = "二";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 13, intCols + 1] = "校";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 14, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 17, intCols + 1] = "验";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 18, intCols + 1] = "收";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 19, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 3] = "施测日期:" + dtpS3.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 7] = "测探工具:测探杆 ";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 10] = "水位:" + txtS4.Text + "m";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// xlsSheet.Cells[1, intCols] = "制表:";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < intCols; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 2, j + 1] = strColName[j];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int tempi = 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < intRows; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < intCols; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == temprows2 && j == tempcols2)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1.Rows[i][j] = myDT1.Rows[i][j].ToString() + "▲";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == temprows1 && j == tempcols1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1.Rows[i][j] = myDT1.Rows[i][j].ToString() + "▼";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Cells[zhanyonghang + i + 3, j + 1] = myDT1.Rows[i][j];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + intRows + 3,6] = "附注:" + txtFuzhu.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.ColumnWidth = 9;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, intCols + 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols + 1]).ColumnWidth = 3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Rows.RowHeight = 18;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).RowHeight = 15;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Name = "宋体";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Size = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Bold = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.WrapText = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[ 2, 1], xlsSheet.Cells[ 2, intCols]).Font.Size = 15;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Name = "宋体";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Size = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Bold = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).WrapText = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + temprows3 + 3, tempcols3], xlsSheet.Cells[zhanyonghang + temprows3 + 3, tempcols3 + 1]).Font.Underline = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < myDT2.Rows.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < myDT2.Columns.Count; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double temp1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (myDT2.Rows[i][j].ToString() == "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
temp1 = 0.123456;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
temp1 = Convert.ToDouble(myDT2.Rows[i][j].ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (j % 2 == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (temp1 == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + i + 3, j + 1] = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if (temp1 == 0.123456)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[i + 3, j + 1] = "";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + i + 3, j + 1], xlsSheet.Cells[zhanyonghang + i + 3, j + 1]).NumberFormatLocal = "#####";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (temp1 > 9)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + i + 3, j + 1], xlsSheet.Cells[zhanyonghang + i + 3, j + 1]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// xlsSheet.get_Range(xlsSheet.Cells[3, 6], xlsSheet.Cells[3, 6]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 4], xlsSheet.Cells[intRows + 2, 4]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 6], xlsSheet.Cells[intRows + 2, 6]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 8], xlsSheet.Cells[intRows + 2, 8]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 10], xlsSheet.Cells[intRows + 2, 10]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 12], xlsSheet.Cells[intRows + 2, 12]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 1, intCols], xlsSheet.Cells[zhanyonghang + 1, intCols]).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols]).Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols]).Borders.Weight = Excel.XlBorderWeight.xlThin;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string FileName = xlsApp.GetSaveAsFilename("断面实测成果表 .xls", "Excel文件 (*.xls), *.xls", 1, "断面实测成果表", "断面实测成果表").ToString().Trim();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (FileName != "False" && FileName != "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.SaveAs(FileName, Excel.XlFileFormat.xlExcel9795, "", "", false, false, false, 1, 1, true);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsBook.Saved = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Workbooks.Close();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Quit();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private void btnSaveAsData_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel.Application xlsApp = new Excel.Application();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel._Workbook xlsBook = xlsApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Excel._Worksheet xlsSheet = (Excel._Worksheet)xlsBook.Worksheets[1];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Activate();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Caption = lblDMMC.Text + "断面实测成果表 - 另存为 ";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataTable myDT1, myDT2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1 = datatable(a,a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT2 = datatable(a,a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double minGaocheng = 0;//Get_min(a1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
string[] strColName = new string[] ...{ "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "起点距m", "河底高程m", "" };
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int intCols = strColName.Length - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int intRows = myDT1.Rows.Count;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int[] intRows1 = new int[myDT1.Rows.Count];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int[] intcols1 = new int[myDT1.Columns.Count];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int minrow = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int mincol = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int zhanyonghang = 3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[2, 7] = lblDMMC.Text + "断面实测成果表";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang+2, intCols + 1] = "制";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 3, intCols + 1] = "表";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 4, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 7, intCols + 1] = "一";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 8, intCols + 1] = "校";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 9, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 12, intCols + 1] = "二";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 13, intCols + 1] = "校";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 14, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 17, intCols + 1] = "验";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 18, intCols + 1] = "收";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 19, intCols + 1] = ":";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 3] = "施测日期:" + dtpS3.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 7] = "测探工具:测探杆 ";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 1, 10] = "水位:" + txtS4.Text + "m";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// xlsSheet.Cells[1, intCols] = "制表:";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < intCols; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + 2, j + 1] = strColName[j];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int tempi = 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < intRows; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < intCols; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == temprows2 && j == tempcols2)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1.Rows[i][j] = myDT1.Rows[i][j].ToString() + "▲";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == temprows1 && j == tempcols1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
myDT1.Rows[i][j] = myDT1.Rows[i][j].ToString() + "▼";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Cells[zhanyonghang + i + 3, j + 1] = myDT1.Rows[i][j];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + intRows + 3,6] = "附注:" + txtFuzhu.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.ColumnWidth = 9;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, intCols + 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols + 1]).ColumnWidth = 3;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Rows.RowHeight = 18;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).RowHeight = 15;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Name = "宋体";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Size = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.Font.Bold = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells.WrapText = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[ 2, 1], xlsSheet.Cells[ 2, intCols]).Font.Size = 15;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Name = "宋体";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Size = 10;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).Font.Bold = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + 2, intCols]).WrapText = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + temprows3 + 3, tempcols3], xlsSheet.Cells[zhanyonghang + temprows3 + 3, tempcols3 + 1]).Font.Underline = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < myDT2.Rows.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < myDT2.Columns.Count; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double temp1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (myDT2.Rows[i][j].ToString() == "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
temp1 = 0.123456;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
temp1 = Convert.ToDouble(myDT2.Rows[i][j].ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (j % 2 == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (temp1 == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[zhanyonghang + i + 3, j + 1] = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if (temp1 == 0.123456)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Cells[i + 3, j + 1] = "";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + i + 3, j + 1], xlsSheet.Cells[zhanyonghang + i + 3, j + 1]).NumberFormatLocal = "#####";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (temp1 > 9)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + i + 3, j + 1], xlsSheet.Cells[zhanyonghang + i + 3, j + 1]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// xlsSheet.get_Range(xlsSheet.Cells[3, 6], xlsSheet.Cells[3, 6]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 4], xlsSheet.Cells[intRows + 2, 4]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 6], xlsSheet.Cells[intRows + 2, 6]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 8], xlsSheet.Cells[intRows + 2, 8]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 10], xlsSheet.Cells[intRows + 2, 10]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//xlsSheet.get_Range(xlsSheet.Cells[3, 12], xlsSheet.Cells[intRows + 2, 12]).NumberFormatLocal = "#####.0";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.Columns.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 1, intCols], xlsSheet.Cells[zhanyonghang + 1, intCols]).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols]).Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.get_Range(xlsSheet.Cells[zhanyonghang + 2, 1], xlsSheet.Cells[zhanyonghang + intRows + 2, intCols]).Borders.Weight = Excel.XlBorderWeight.xlThin;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string FileName = xlsApp.GetSaveAsFilename("断面实测成果表 .xls", "Excel文件 (*.xls), *.xls", 1, "断面实测成果表", "断面实测成果表").ToString().Trim();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (FileName != "False" && FileName != "")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsSheet.SaveAs(FileName, Excel.XlFileFormat.xlExcel9795, "", "", false, false, false, 1, 1, true);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsBook.Saved = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Workbooks.Close();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
xlsApp.Quit();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- C#调用WORD处理的实例代码(包含excel)
- 如何在unity3D的C#中调用libsqlite3(完整代码)
- C#代码与javaScript函数的相互调用
- 操作EXCEL代码(c#完全版)
- C#导出EXCEL代码1
- vb/vb.net/C#调用Excel
- 如何在C#中调用Excel
- 在.Net中用C#调用Windows系统信息的代码
- SQL中KILL进程号语句在C#代码中调用
- C#利用NOPI处理Excel的代码
- C#操作excel,如何调用模板
- 使 WebBrowser 更简单的插入、调用执行脚本, 可安装 jQuery 脚本的 C# 开源代码 - IEBrowser
- Unity调用外接摄像头的实例代码(C#)
- C# .Net动态调用webService实现思路及代码
- ASP.NET前台javascript与c#后台代码调用
- ThinkPHP中调用PHPExcel的实现代码
- 在PowerShell中调用C#代码创建对象类型
- 用WebBrowser承载视图,html编写页面,c#编写后端代码;用js调用后端代码,传入function参数作为回调;
- C#调用NPOI组件读取excel表格数据转为datatable写入word表格中并向word中插入图片/文字/书签 获得书签列表
- javascript如何调用C#后代码中的过程 和ASP.NET调用JS乱码解决方案