ctrl+k,ctrl+d代码自动整理快捷键
ctrl+e,c 注释选中的代码
ctrl+e,u 取消注释选中的代码c#
streamwrite 的声明 using system.io;ide
c# 调用计算器的方法:System.Diagnostics.Process.Start("calc.exe");
调用记事本的方法:System.Diagnostics.Process.Start("notepad.exe");excel
//将datagridview中的数据转换成excel数据的方法:对象
public bool ExportDataGridview(DataGridView gridView,bool isShowExcle)
{
if (gridView.Rows.Count == 0)
return false;
//创建Excel对象string
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();it
//Microsoft.Office.Interop.Excel._Application excel = new Microsoft.Office.Interop.Excel.ApplicationClass(); io
excel.Application.Workbooks.Add(true);
excel.Visible = isShowExcle;
//生成字段名称
for (int i = 0; i < gridView.ColumnCount; i++)
{
excel.Cells[1, i + 1] = gridView.Columns[i].HeaderText;
}
//填充数据
for (int i = 0; i < gridView.RowCount-1; i++)
{
for (int j = 0; j < gridView.ColumnCount; j++)
{
if (gridView[j, i].ValueType == typeof(string))
{
excel.Cells[i + 2, j + 1] = "'" + gridView[j, i].Value.ToString();
}
else
{
excel.Cells[i + 2, j + 1] = gridView[j, i].Value.ToString();
}
}
}
return true;
}class