本文介绍了如何在C#中读取excell cell值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
我将在.net中创建应用程序以读取Excell文件。
我想阅读更多信息一次70个文件。每个文件包含一个固定单元格值,我想读取该单元格。
我尝试从一个站点获取此代码。
此代码工作正常,但我想要提高性能。
Hello All,
I am going to create application in .net for read Excell File.
I want to read more then 70 file at a time. every file contain one fix cell value and i want to read that cell.
I try and get this code from one site.
This code is working fine but i want to improve performance.
public string readExcel()
{
object _row = 3;
object _column = 3;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;
excelApp.ScreenUpdating = false;
excelApp.DisplayAlerts = false;
Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(@"D:\123.xlsx", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Microsoft.Office.Interop.Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Sheet1";
Microsoft.Office.Interop.Excel.Worksheet excelWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(currentSheet);
Microsoft.Office.Interop.Excel.Range range = (Microsoft.Office.Interop.Excel.Range)excelWorksheet.UsedRange;
string sValue = (range.Cells[_row, _column] as Microsoft.Office.Interop.Excel.Range).Value2.ToString();
return sValue;
}
如果您知道如何提高性能,请建议我吗?
Please suggest me if you know how to improve performance?
推荐答案
这篇关于如何在C#中读取excell cell值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!