赞
踩
using System; using System.IO; using OfficeOpenXml; namespace ConsoleApplication1 { internal class Program { public static void Main(string[] args) { ReadData("zzsTest.xlsx",1); Console.ReadKey(); } private static void ReadData(string path,int sheetIndex) { var fs = new FileStream(path, FileMode.Open, FileAccess.Read); var excel = new ExcelPackage(fs); var sheet = excel.Workbook.Worksheets[sheetIndex]; var row = sheet.Dimension.End.Row; var col = sheet.Dimension.End.Column; Console.WriteLine(row); Console.WriteLine(col); for (var i = 1; i <= row; i++) { for (var j = 1; j <= col; j++) { Console.WriteLine(sheet.Cells[i, j].Value); } } excel.Dispose(); fs.Dispose(); Console.WriteLine("完成"); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。