//1.添加引用-〉com-〉microsoft excel 11.0
//2.若出现错误:命名空间“Microsoft.Office”中不存在类型或命名空间名称“Interop”(是缺少程序集引用吗?)
//解决方法:先删除引用中的Excel,然后找到文件Microsoft.Office.Interop.Excel.dll,手动添加该文件的引用 using System;
using System.Data;
using System.Reflection;
using System.IO;
using Microsoft.Office.Core;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel; namespace Wage.Common
{
/// <summary>
/// 作者 Li Aimin (原创)
/// 功能描述:C#对Excel报表进行操作
/// 创建时间:2006-01-17, 修改时间:2007-1-14
/// 说明:在工程中需要添加 Excel11.0对象库的引用(Office 2000为Excel9.0,Office XP为Excel10.0);
/// 需要在Dcom中配置Excel应用程序的权限;
/// 服务器需要安装Office2003
/// </summary>
public class ExcelLib
{
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrgrfexcelapplicationobject.asp
#region Variables
private Excel.Application excelApplication = null;
private Excel.Workbooks excelWorkBooks = null;
private Excel.Workbook excelWorkBook = null;
private Excel.Worksheet excelWorkSheet = null;
private Excel.Range excelRange = null;//Excel Range Object,多种用途
private Excel.Range excelCopySourceRange = null;//Excel Range Object
private int excelActiveWorkSheetIndex; //活动工作表索引
private string excelOpenFileName = ""; //操作Excel的路径
private string excelSaveFileName = ""; //保存Excel的路径
#endregion #region Properties
public int ActiveSheetIndex
{
get
{
return excelActiveWorkSheetIndex;
}
set
{
excelActiveWorkSheetIndex = value;
}
}
public string OpenFileName
{
get
{
return excelOpenFileName;
}
set
{
excelOpenFileName = value;
}
}
public string SaveFileName
{
get
{
return excelSaveFileName;
}
set
{
excelSaveFileName = value;
}
}
#endregion //
//--------------------------------------------------------------------------------------------------------
/// <summary>
/// 构造函数;
/// </summary>
public ExcelLib()
{
excelApplication = null;//Excel Application Object
excelWorkBooks = null;//Workbooks
excelWorkBook = null;//Excel Workbook Object
excelWorkSheet = null;//Excel Worksheet Object
ActiveSheetIndex = 1; //默认值活动工作簿为第一个;设置活动工作簿请参阅SetActiveWorkSheet()
}
/// <summary>
/// 以excelOpenFileName为模板新建Excel文件
/// </summary>
public bool OpenExcelFile()
{
if (excelApplication != null) CloseExcelApplication(); //检查文件是否存在
if (excelOpenFileName == "")
{
throw new Exception("请选择文件!");
}
if (!File.Exists(excelOpenFileName))
{ throw new Exception(excelOpenFileName + "该文件不存在!");//该异常如何处理,由什么处理????
}
try
{
excelApplication = new Excel.ApplicationClass();
excelWorkBooks = excelApplication.Workbooks;
excelWorkBook = ((Excel.Workbook)excelWorkBooks.Open(excelOpenFileName, Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets[excelActiveWorkSheetIndex];
excelApplication.Visible = false; return true;
}
catch (Exception e)
{
CloseExcelApplication();
MessageBox.Show("(1)没有安装Excel 2003;(2)或没有安装Excel 2003 .NET 可编程性支持;\n详细信息:"
+e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//throw new Exception(e.Message);
return false;
}
} /// <summary>
/// 读取一个Cell的值
/// </summary>
/// <param name="CellRowID">要读取的Cell的行索引</param>
/// <param name="CellColumnID">要读取的Cell的列索引</param>
/// <returns>Cell的值</returns>
public string getOneCellValue(int CellRowID, int CellColumnID)
{
if (CellRowID <= 0)
{
throw new Exception("行索引超出范围!");
}
string sValue = "";
try
{
sValue = ((Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID]).Text.ToString();
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
return (sValue);
}
/// <summary>
/// 读取一个连续区域的Cell的值(矩形区域,包含一行或一列,或多行,多列),返回一个一维字符串数组。
/// </summary>
/// <param name="StartCell">StartCell是要写入区域的左上角单元格</param>
/// <param name="EndCell">EndCell是要写入区域的右下角单元格</param>
/// <returns>值的集合</returns>
public string[] getCellsValue(string StartCell, string EndCell)
{
string[] sValue = null;
//try
//{
excelRange = (Excel.Range)excelWorkSheet.get_Range(StartCell, EndCell);
sValue = new string[excelRange.Count];
int rowStartIndex = ((Excel.Range)excelWorkSheet.get_Range(StartCell, StartCell)).Row; //起始行号
int columnStartIndex = ((Excel.Range)excelWorkSheet.get_Range(StartCell, StartCell)).Column; //起始列号
int rowNum = excelRange.Rows.Count; //行数目
int columnNum = excelRange.Columns.Count; //列数目
int index = 0;
for (int i = rowStartIndex; i < rowStartIndex + rowNum; i++)
{
for (int j = columnStartIndex; j < columnNum + columnStartIndex; j++)
{
//读到空值null和读到空串""分别处理
sValue[index] = ((Excel.Range)excelWorkSheet.Cells[i, j]).Text.ToString();
index++;
}
}
//}
//catch (Exception e)
//{
// CloseExcelApplication();
// throw new Exception(e.Message);
//} return (sValue);
} /// <summary>
/// 读取所有单元格的数据(矩形区域),返回一个datatable.假设所有单元格靠工作表左上区域。
/// </summary>
public DataTable getAllCellsValue()
{
int columnCount = getTotalColumnCount();
int rowCount = getTotalRowCount();
DataTable dt = new DataTable();
//设置datatable列的名称
for (int columnID = 1; columnID <= columnCount; columnID++)
{
dt.Columns.Add(((Excel.Range)excelWorkSheet.Cells[1, columnID]).Text.ToString());
} for (int rowID = 2; rowID <= rowCount; rowID++)
{
DataRow dr = dt.NewRow();
for (int columnID = 1; columnID <= columnCount; columnID++)
{
dr[columnID - 1] = ((Excel.Range)excelWorkSheet.Cells[rowID, columnID]).Text.ToString();
//读到空值null和读到空串""分别处理
}
dt.Rows.Add(dr);
}
return (dt);
}
public int getTotalRowCount()
{//当前活动工作表中有效行数(总行数)
int rowsNumber = 0;
try
{
while (true)
{
if (((Excel.Range)excelWorkSheet.Cells[rowsNumber + 1, 1]).Text.ToString().Trim() == "" &&
((Excel.Range)excelWorkSheet.Cells[rowsNumber + 2, 1]).Text.ToString().Trim() == "" &&
((Excel.Range)excelWorkSheet.Cells[rowsNumber + 3, 1]).Text.ToString().Trim() == "")
break;
rowsNumber++;
}
}
catch
{
return -1;
}
return rowsNumber;
}
/// <summary>
/// 当前活动工作表中有效列数(总列数)
/// </summary>
/// <param></param>
public int getTotalColumnCount()
{
int columnNumber = 0;
try
{
while (true)
{
if (((Excel.Range)excelWorkSheet.Cells[1, columnNumber + 1]).Text.ToString().Trim() == "" &&
((Excel.Range)excelWorkSheet.Cells[1, columnNumber + 2]).Text.ToString().Trim() == "" &&
((Excel.Range)excelWorkSheet.Cells[1, columnNumber + 3]).Text.ToString().Trim() == "")
break;
columnNumber++;
}
}
catch
{
return -1;
}
return columnNumber;
} /// <summary>
/// 向一个Cell写入数据
/// </summary>
/// <param name="CellRowID">CellRowID是cell的行索引</param>
/// <param name="CellColumnID">CellColumnID是cell的列索引</param>
///<param name="Value">要写入该单元格的数据值</param>
public void setOneCellValue(int CellRowID, int CellColumnID, string Value)
{
try
{
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.Value2 = Value;//Value2?
//Gets or sets the value of the NamedRange control.
//The only difference between this property and the Value property is that Value2 is not a parameterized property.
excelRange = null;
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
/// <summary>
/// 设置活动工作表
/// </summary>
/// <param name="SheetIndex">要设置为活动工作表的索引值</param>
public void SetActiveWorkSheet(int SheetIndex)
{
if (SheetIndex <= 0)
{
throw new Exception("索引超出范围!");
}
try
{
ActiveSheetIndex = SheetIndex;
excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets[ActiveSheetIndex];
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
/// <summary>
/// 向连续区域一次性写入数据;只有在区域连续和写入的值相同的情况下可以使用方法
/// </summary>
/// <param name="StartCell">StartCell是要写入区域的左上角单元格</param>
/// <param name="EndCell">EndCell是要写入区域的右下角单元格</param>
/// <param name="Value">要写入指定区域所有单元格的数据值</param>
public void setCellsValue(string StartCell, string EndCell, string Value)
{
try
{
excelRange = excelWorkSheet.get_Range(StartCell, EndCell);
excelRange.Value2 = Value;
excelRange = null;
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
/// <summary>
/// 给一行写数据
/// </summary>
public void setOneLineValues(int LineID, int StartCellColumnID, int EndCellColumnID, string[] Values)////已经测试
{
//用1-19号元素 //if (Values.Length!=EndCellColumnID-StartCellColumnID)
//{
// throw new Exception("单元格数目与提供的值的数目不一致!");
//}
for (int i = StartCellColumnID; i <= EndCellColumnID; i++)
{
setOneCellValue(LineID, i, Values[i]);
}
}
public void setCellsBorder(string startCell, string endCell)
{
//设置某个范围内的单元格的边框
excelRange = excelWorkSheet.get_Range(startCell, endCell);
excelRange.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;
//excelRange.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlContinuous;
} public void setOneCellBorder(int CellRowID, int CellColumnID)
{
//设置某个单元格的边框
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID]; excelRange.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
excelRange.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
//excelRange.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;
//excelRange.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlContinuous;
} public void SetColumnWidth(string startCell, string endCell, int size)
{
//设置某个范围内的单元格的列的宽度
excelRange = excelWorkSheet.get_Range(startCell, endCell);
excelRange.ColumnWidth = size;
} public void SetOneCellFont(int CellRowID, int CellColumnID, string fontName, int fontSize)
{
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.Font.Name = fontName;
excelRange.Font.Size = fontSize;
} public void SetOneCellHorizontalAlignment(int CellRowID, int CellColumnID, Excel.Constants alignment)
{
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.HorizontalAlignment = alignment; } public void SetOneCellColumnWidth(int CellRowID, int CellColumnID, int size)
{
//设置某个单元格的列的宽度
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.ColumnWidth = size; } /// <summary>
/// 设置一个Cell的数据格式
/// </summary>
/// <param name="CellRowID">CellRowID是cell的行索引</param>
/// <param name="CellColumnID">CellColumnID是cell的列索引</param>
///<param name="Value">数据格式</param>
public void setOneCellNumberFormat(int CellRowID, int CellColumnID, string numberFormat)
{
try
{
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.NumberFormatLocal = numberFormat; excelRange = null;
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
public void SetRowHeight(string startCell, string endCell, int size)
{
//设置某个范围内的单元格的行的高度
excelRange = excelWorkSheet.get_Range(startCell, endCell);
excelRange.RowHeight = size; }
public void SetRowHeight(int CellRowID, int CellColumnID, float size)
{
//设置某个范围内的单元格的行的高度
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.RowHeight = size; }
public void SetOneCellRowHeight(int CellRowID, int CellColumnID, int size)
{
//设置某个单元格的行的高度
excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
excelRange.RowHeight = size; } /// <summary>
/// 拷贝区域.限制:在同一个工作表中复制
/// </summary>
/// <param name="SourceStart">源区域的左上角单元格</param>
/// <param name="SourceEnd">源区域的右下角单元格</param>
/// <param name="DesStart">目标区域的左上角单元格</param>
/// <param name="DesEnd">目标区域的右下角单元格</param>
public void CopyCells(string SourceStart, string SourceEnd, string DesStart, string DesEnd)
{
try
{
excelCopySourceRange = excelWorkSheet.get_Range(SourceStart, SourceEnd);
excelRange = excelWorkSheet.get_Range(DesStart, DesEnd);
excelCopySourceRange.Copy(excelRange); excelCopySourceRange = null;
excelRange = null;
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
public void CopyWorksheet(int SourceWorksheetIndex, int DesWorksheetIndex)
{
try
{
// Sheets("Sheet2").Select
//Sheets("Sheet2").Copy After:=Sheets(3)
Excel.Worksheet sheetSource = (Excel.Worksheet)excelWorkBook.Worksheets[SourceWorksheetIndex];
sheetSource.Select(Missing.Value);
Excel.Worksheet sheetDest = (Excel.Worksheet)excelWorkBook.Worksheets[DesWorksheetIndex];
sheetSource.Copy(Missing.Value, sheetDest);
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
} /// <summary>
/// 插入一行
/// </summary>
/// <param name="CellRowID">要插入所在行的索引位置,插入后其原有行下移</param>
/// <param name="RowNum">要插入行的个数</param>
public void InsertRow(int CellRowID, int RowNum)//插入空行
{
if (CellRowID <= 0)
{
throw new Exception("行索引超出范围!");
}
if (RowNum <= 0)
{
throw new Exception("插入行数无效!");
}
try
{
excelRange = (Excel.Range)excelWorkSheet.Rows[CellRowID, Missing.Value];
for (int i = 0; i < RowNum; i++)
{
excelRange.Insert(Excel.XlDirection.xlDown, Missing.Value);
}
excelRange = null;
}
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
} /// <summary>
/// 保存Excel文件
/// </summary> public Excel.Range FindFirstRange(Excel.Range xlRange, string FindText)//查找//没有测试
{
//查找第一个满足的区域
//Search for the first match
Excel.Range firstFind = null;
firstFind = xlRange.Find(FindText, Missing.Value, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, Missing.Value, Missing.Value);
return firstFind; //如果没找到,返回空
}
//http://msdn.microsoft.com/library/en-us/dv_wrcore/html/wrtskHowToSearchForTextInWorksheetRanges.asp?frame=true /// <summary>
/// 当前活动工作表中有效行数(总行数)
/// </summary>
/// <param></param> /// <summary>
/// 判断单元格是否有数据
/// </summary>
public bool CellValueIsNull(int CellLineID, int CellColumnID)////已经测试
{ //判断单元格是否有数据
if ((((Excel.Range)excelWorkSheet.Cells[CellLineID, CellColumnID]).Text.ToString().Trim() != ""))
return false;
return true;
} public void newWorkbook(string excelTemplate, string fileName)
{
//以excelTemplate为模板新建文件fileName
//excelApplication.
excelWorkBook = excelWorkBooks.Add(excelTemplate);
SaveFileName = "";
SaveExcel();
}
public void newWorksheet()
{
excelWorkBook.Worksheets.Add(Missing.Value, Missing.Value, 1, Missing.Value);
}
public void setWorksheetName(int sheetIndex, string worksheetName)
{
// Missing.Value
Excel._Worksheet sheet = (Excel._Worksheet)(excelWorkBook.Worksheets[(object)sheetIndex]);
sheet.Name = worksheetName;
} public void mergeOneLineCells(string startCell, string endCell)
{
//合并一行单元格
excelRange = excelWorkSheet.get_Range(startCell, endCell);
//excelRange.Merge(true);
excelRange.MergeCells = true;
} public void HorizontalAlignmentCells(string startCell, string endCell, Excel.Constants alignment)
{
//水平对齐一行单元格
excelRange = excelWorkSheet.get_Range(startCell, endCell);
excelRange.HorizontalAlignment = alignment;
} public void VerticalAlignmentCells(string startCell, string endCell, Excel.Constants alignment)
{
//垂直对齐一行单元格
excelRange = excelWorkSheet.get_Range(startCell, endCell);
excelRange.VerticalAlignment = alignment;
} //实现列号-〉字母 (26-〉Z,27->AA)
private string ConvertColumnIndexToChar(int columnIndex)
{
if (columnIndex < 1 || columnIndex > 256)
{
MessageBox.Show("columnIndex=" + columnIndex + ",超出了有效范围(1-256)");
return "A";
}
if (columnIndex >= 1 && columnIndex <= 26)//1--26
{
return "AA";
}
if (columnIndex >= 27 && columnIndex <= 256)//27--256
{
return "AA";
}
return "A";
}
//字母-〉列号 Z-〉26
public void SaveExcel()
{
if (excelSaveFileName == "")
{
throw new Exception("未指定要保存的文件名");
}
try
{
//excelWorkSheet.SaveAs(excelSaveFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value);
excelWorkSheet.SaveAs(excelSaveFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value); }
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
} //--------------------------------------------------------------------------------------------------------
/// <summary>
/// 保存Excel文件,格式xml.
/// </summary>
public void SaveExcelAsXML()
{
if (excelSaveFileName == "")
{
throw new Exception("未指定要保存的文件名");
}
try
{
//excelWorkSheet.SaveAs(excelSaveFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value);
excelWorkSheet.SaveAs(excelSaveFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value); }
catch (Exception e)
{
CloseExcelApplication();
throw new Exception(e.Message);
}
}
//--------------------------------------------------------------------------------------------------------
/// <summary>
/// 关闭Excel文件,释放对象;最后一定要调用此函数,否则会引起异常
/// </summary>
/// <param></param>
public void CloseExcelApplication()
{
try
{
excelWorkBooks = null;
excelWorkBook = null;
excelWorkSheet = null;
excelRange = null;
if (excelApplication != null)
{
excelApplication.Workbooks.Close();
//Object missing = Type.Missing;
excelApplication.Quit();
excelApplication = null;
//ReleaseAllRef(excelApplication);//Error }
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
private void ReleaseAllRef(Object obj)
{//ReleaseComObject()方法可以使RCW减少一个对COM组件的引用,并返回减少一个引用后RCW对COM组件的剩余引用数量。
//我们用一个循环,就可以让RCW将所有对COM组件的引用全部去掉。
try
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) > 1) ;
}
finally
{
obj = null;
}
} }
}

  

无法嵌入互操作类型“Microsoft.Office.Interop.Excel.ApplicationClass”。请改用适用的接口。

winform下对datagridview进行导出时候,写了一句:
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); 导致结果如下: 类型“Microsoft.Office.Interop.Excel.ApplicationClass”未定义构造函数
无法嵌入互操作类型“Microsoft.Office.Interop.Excel.ApplicationClass”。请改用适用的接口。 解决办法是将引用的DLL:Microsoft.Office.Interop.Excel;的嵌入互操作类型改为false,就可以了。 下载地址:https://files.cnblogs.com/files/emanlee/ExcelLib.rar 转载链接:http://www.cnblogs.com/emanlee/archive/2007/05/31/766520.html 引用代码
        static void Main(string[] args)
{
ExcelLib excel = new ExcelLib();
excel.OpenFileName = @"C:\Users\lc\Desktop\test.xlsx";
excel.SaveFileName = @"C:\Users\lc\Desktop\test002.xlsx";
excel.OpenExcelFile();
int columns = excel.getTotalColumnCount();
int rows = excel.getTotalRowCount();
string value = excel.getOneCellValue(1, 1);
for (int row = 1; row <= rows; row++)
{
for (int column = 1; column <= columns; column++)
{
string xx = excel.getOneCellValue(row, column);
Console.WriteLine(xx);
}
} excel.setOneCellValue(4, 4, "xyz222");
excel.SaveExcel();
}

  

[转]C#对Excel报表进行操作(读写和基本操作)的更多相关文章

  1. excel、xls文件读写操作

    python 常用的excel.xls文件读写操作,有两个模块 xlrd:读 xlwt:写 本次先写一个读的例子: class CaseData(object): def __init__(self, ...

  2. 在.NET中使用EPPlus生成Excel报表 .

    --摘抄自:http://blog.csdn.net/zhoufoxcn/article/details/14112473 在开发.NET应用中可能会遇到需要生成带图表(Chart)的Excel报表的 ...

  3. Java使用POI实现数据导出excel报表

    Java使用POI实现数据导出excel报表 在上篇文章中,我们简单介绍了java读取word,excel和pdf文档内容 ,但在实际开发中,我们用到最多的是把数据库中数据导出excel报表形式.不仅 ...

  4. 10、借助POI实现Java生成并打印excel报表(1)

    10.1.了解 Apache POI 实际开发中,用到最多的是把数据库中数据导出生成报表,尤其是在生产管理或者财务系统中用的非常普遍.生成报表格式一般是EXCEL或者PDF .利用Apache  PO ...

  5. C#对Excel的图文操作

    1.打印Excel 目前的商业工具如水晶报表,ActiveReport等,都提供了灵活,强大的功能,但是对于比较特殊化的表格,特别是国内的一些应用,都是一个个的格子组成的,这样要是用线来一根根画就比较 ...

  6. ASP.NET MVC 4.0 中使用NPOI 2.2.0 按模板生成Excel报表

    使用 NPOI 你就可以在没有安装 Office 或者相应环境的机器上对 WORD/EXCEL 文档进行读写.NPOI是构建在POI 3.x版本之上的,它可以在没有安装Office的情况下对Word/ ...

  7. 如何在没有安装微软Excel环境下操作Excel文件?

    在以前接触的项目中,由于很多客户对微软Excel的操作比较熟练,客户经常要求系统支持对Excel文件的读写.用.NET传统方法对Excel进行读写时,往往会涉及到不同版本兼容的问题,导致在本地测试一切 ...

  8. ASP.NET打印EXCEl报表技术总结

    序言:我们在做企业项目或者一些管理系统的时候往往会用到导出到excel报表这项功能,下面我介绍的是用windows自带的excel来打印 首先必须引入:Interop.Excel.dll.Intero ...

  9. xBIM IFC 输出 Excel 报表

    目录 xBIM 应用与学习 (一) xBIM 应用与学习 (二) xBIM 基本的模型操作 xBIM 日志操作 XBIM 3D 墙壁案例 xBIM 格式之间转换 xBIM 使用Linq 来优化查询 x ...

随机推荐

  1. Light项目---vue搭建前端时遇见的一些问题

    css样式中设置的: opacity 表示透明度 将js对象存储到localStorge中 的时候,直接存储是不行的,会变成[object Object],都是这样的数据, 需要将其进行JSON化处理 ...

  2. JAVA基础学习-多态 对象转型 final

    一.多态的产生条件 1:继承  存在继承的类之间 2:方法重装 3:父类继承子类重装的方法 子类的对象 也是属于父类的 二:对象的转型 1:向上转型:当子类转型成父类时 例如:Animal a = n ...

  3. matlab filtfilt 函数

    紧接上一篇,简单分析matlab中的非常好用的 filtfilt 函数,一款零相移滤波函数. 其matlab中的语法如下: y = filtfilt(data,x);1非常简单,不是一般的简单!然而, ...

  4. 解决mybatisplus saveBatch 或者save 无法插入主键问题

    解决mybatisplus saveBatch 或者save 无法插入主键问题 通过跟踪源码后得出结论,由于插入的表的主键不是自增的,而是手动赋值的,所以在调用saveBatch 执行的sql语句是没 ...

  5. git的使用(扫盲)

    之前一直是通过图形化工具使用git,前两天练习用命令上传代码,遇到不少问题,最终还是解决了,在这里总结一下. 通过一个例子来演示一下.首先去github上面创建一个仓库. 创建好之后,就可以上传文件了 ...

  6. 统计所有小于非负整数 n 的质数的数量,埃拉托斯特尼筛法

    素数的定义:质数又称素数.一个大于1的自然数,除了1和它自身外,不能被其他自然数整除的数叫做质数. 1.暴力算法: 令i=2; 当i<n的时候,我们循环找出2-i的质数,即让i%(2~i-1), ...

  7. spring boot 四大组件之Auto Configuration

    SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...

  8. Dart编程实例 - Final 关键字

    Dart编程实例 - Final 关键字 void main() { final val1 = 12; print(val1); } 本文转自:http://codingdict.com/articl ...

  9. 【TCP】SYN攻击

    TCP握手协议 在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接.第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确 ...

  10. luoguP2148 [SDOI2009]E&D [sg函数][组合游戏]

    题目描述 小E 与小W 进行一项名为“E&D”游戏. 游戏的规则如下: 桌子上有2n 堆石子,编号为1..2n.其中,为了方便起见,我们将第2k-1 堆与第2k 堆 (1 ≤ k ≤ n)视为 ...