C #을 사용하여 Excel 파일의 데이터를 읽는 방법은 무엇입니까?
C #을 사용하여 Excel 파일을 읽는 방법은 무엇입니까? 읽기 용으로 Excel 파일을 열고 클립 보드에 복사하여 이메일 형식을 검색하는데 어떻게해야하는지 모르겠습니다.
FileInfo finfo;
Excel.ApplicationClass ExcelObj = new Excel.ApplicationClass();
ExcelObj.Visible = false;
Excel.Workbook theWorkbook;
Excel.Worksheet worksheet;
if (listView1.Items.Count > 0)
{
foreach (ListViewItem s in listView1.Items)
{
finfo = new FileInfo(s.Text);
if (finfo.Extension == ".xls" || finfo.Extension == ".xlsx" || finfo.Extension == ".xlt" || finfo.Extension == ".xlsm" || finfo.Extension == ".csv")
{
theWorkbook = ExcelObj.Workbooks.Open(s.Text, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, false, false);
for (int count = 1; count <= theWorkbook.Sheets.Count; count++)
{
worksheet = (Excel.Worksheet)theWorkbook.Worksheets.get_Item(count);
worksheet.Activate();
worksheet.Visible = false;
worksheet.UsedRange.Cells.Select();
}
}
}
}
확인,
Excel VSTO 프로그래밍에 대해 이해하기 더 어려운 개념 중 하나는 배열과 같은 셀을 참조하지 않고 Worksheet[0][0]
A1 셀을 제공하지 않고 오류가 발생한다는 것입니다. Excel이 열려있을 때 A1을 입력하더라도 실제로는 A1 범위에 데이터를 입력하는 것입니다. 따라서 셀을 명명 된 범위라고합니다. 예를 들면 다음과 같습니다.
Excel.Worksheet sheet = workbook.Sheets["Sheet1"] as Excel.Worksheet;
Excel.Range range = sheet.get_Range("A1", Missing.Value)
이제 문자 그대로 다음을 입력 할 수 있습니다.
range.Text // this will give you the text the user sees
range.Value2 // this will give you the actual value stored by Excel (without rounding)
다음과 같이하고 싶다면 :
Excel.Range range = sheet.get_Range("A1:A5", Missing.Value)
if (range1 != null)
foreach (Excel.Range r in range1)
{
string user = r.Text
string value = r.Value2
}
더 나은 방법이 있을지 모르지만 이것은 나를 위해 일했습니다.
사용 Value2
하지 않고 사용해야하는 이유 Value
는 Value
속성이 매개 변수화되어 있고 C #에서 아직 지원하지 않기 때문입니다.
정리 코드에 관해서는 내일 출근하면 코드를 가지고 있지 않지만 매우 상용구라고 게시 할 것입니다. 생성 한 역순으로 개체를 닫고 해제하면됩니다. Using()
Excel.Application 또는 Excel.Workbook이을 구현하지 않기 때문에 블록을 사용할 수 없으며 IDisposable
정리하지 않으면 메모리에 Excel 개체가 중단됩니다.
노트 :
Visibility
Excel이 표시되지 않는 속성을 설정 하지 않으면 사용자가 당황 할 수 있지만 데이터를 추출하려는 경우 충분할 수 있습니다.- OleDb도 가능합니다.
이 과정이 시작되기를 바랍니다. 추가 설명이 필요하면 알려주세요. 나는 완전한 게시 할 것이다
다음은 전체 샘플입니다.
using System;
using System.IO;
using System.Reflection;
using NUnit.Framework;
using ExcelTools = Ms.Office;
using Excel = Microsoft.Office.Interop.Excel;
namespace Tests
{
[TestFixture]
public class ExcelSingle
{
[Test]
public void ProcessWorkbook()
{
string file = @"C:\Users\Chris\Desktop\TestSheet.xls";
Console.WriteLine(file);
Excel.Application excel = null;
Excel.Workbook wkb = null;
try
{
excel = new Excel.Application();
wkb = ExcelTools.OfficeUtil.OpenBook(excel, file);
Excel.Worksheet sheet = wkb.Sheets["Data"] as Excel.Worksheet;
Excel.Range range = null;
if (sheet != null)
range = sheet.get_Range("A1", Missing.Value);
string A1 = String.Empty;
if( range != null )
A1 = range.Text.ToString();
Console.WriteLine("A1 value: {0}", A1);
}
catch(Exception ex)
{
//if you need to handle stuff
Console.WriteLine(ex.Message);
}
finally
{
if (wkb != null)
ExcelTools.OfficeUtil.ReleaseRCM(wkb);
if (excel != null)
ExcelTools.OfficeUtil.ReleaseRCM(excel);
}
}
}
}
내일 ExcelTools의 함수를 게시 할 것입니다. 저도 그 코드를 가지고 있지 않습니다.
편집 : 약속대로 ExcelTools의 기능이 필요할 수 있습니다.
public static Excel.Workbook OpenBook(Excel.Application excelInstance, string fileName, bool readOnly, bool editable,
bool updateLinks) {
Excel.Workbook book = excelInstance.Workbooks.Open(
fileName, updateLinks, readOnly,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, editable, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
return book;
}
public static void ReleaseRCM(object o) {
try {
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
} catch {
} finally {
o = null;
}
}
솔직히 말하면 VB.NET을 사용하면 훨씬 쉽습니다. 내가 작성하지 않았기 때문에 C #에 있습니다. VB.NET은 옵션 매개 변수를 잘 수행하지만 C #은 그렇지 않으므로 Type.Missing입니다. Type.Missing을 두 번 연속 입력하면 방에서 비명을 질렀습니다!
질문에 대해서는 다음을 시도 할 수 있습니다.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.find(VS.80).aspx
회의에서 돌아 오면 예제를 게시하겠습니다 ... 건배
편집 : 다음은 예입니다.
range = sheet.Cells.Find("Value to Find",
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Excel.XlSearchDirection.xlNext,
Type.Missing,
Type.Missing, Type.Missing);
range.Text; //give you the value found
다음은이 사이트에서 영감을 얻은 또 다른 예 입니다 .
range = sheet.Cells.Find("Value to find", Type.Missing, Type.Missing,Excel.XlLookAt.xlWhole,Excel.XlSearchOrder.xlByColumns,Excel.XlSearchDirection.xlNext,false, false, Type.Missing);
매개 변수를 이해하는 데 도움이됩니다.
추신 : 저는 COM 자동화를 배우는 것을 좋아하는 이상한 사람들 중 한 명입니다. 이 모든 코드는 매주 월요일에 실험실에서 1000 개 이상의 스프레드 시트를 처리해야하는 작업을 위해 작성한 도구에서 생성되었습니다.
Microsoft.Office.Interop.Excel
어셈블리를 사용 하여 Excel 파일을 처리 할 수 있습니다 .
- 프로젝트를 마우스 오른쪽 버튼으로 클릭하고로 이동합니다
Add reference
. Microsoft.Office.Interop.Excel 어셈블리를 추가합니다. using Microsoft.Office.Interop.Excel;
어셈블리를 사용하기 위해 포함하십시오 .
다음은 샘플 코드입니다.
using Microsoft.Office.Interop.Excel;
//create the Application object we can use in the member functions.
Microsoft.Office.Interop.Excel.Application _excelApp = new Microsoft.Office.Interop.Excel.Application();
_excelApp.Visible = true;
string fileName = "C:\\sampleExcelFile.xlsx";
//open the workbook
Workbook workbook = _excelApp.Workbooks.Open(fileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
//select the first sheet
Worksheet worksheet = (Worksheet)workbook.Worksheets[1];
//find the used range in worksheet
Range excelRange = worksheet.UsedRange;
//get an object array of all of the cells in the worksheet (their values)
object[,] valueArray = (object[,])excelRange.get_Value(
XlRangeValueDataType.xlRangeValueDefault);
//access the cells
for (int row = 1; row <= worksheet.UsedRange.Rows.Count; ++row)
{
for (int col = 1; col <= worksheet.UsedRange.Columns.Count; ++col)
{
//access each cell
Debug.Print(valueArray[row, col].ToString());
}
}
//clean up stuffs
workbook.Close(false, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(workbook);
_excelApp.Quit();
Marshal.FinalReleaseComObject(_excelApp);
OleDbConnection을 생성하지 않는 이유는 무엇입니까? 인터넷에는 사용 가능한 많은 리소스가 있습니다. 다음은 예입니다.
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filename+";Extended Properties=Excel 8.0");
con.Open();
try
{
//Create Dataset and fill with imformation from the Excel Spreadsheet for easier reference
DataSet myDataSet = new DataSet();
OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM ["+listname+"$]" , con);
myCommand.Fill(myDataSet);
con.Close();
richTextBox1.AppendText("\nDataSet Filled");
//Travers through each row in the dataset
foreach (DataRow myDataRow in myDataSet.Tables[0].Rows)
{
//Stores info in Datarow into an array
Object[] cells = myDataRow.ItemArray;
//Traverse through each array and put into object cellContent as type Object
//Using Object as for some reason the Dataset reads some blank value which
//causes a hissy fit when trying to read. By using object I can convert to
//String at a later point.
foreach (object cellContent in cells)
{
//Convert object cellContect into String to read whilst replacing Line Breaks with a defined character
string cellText = cellContent.ToString();
cellText = cellText.Replace("\n", "|");
//Read the string and put into Array of characters chars
richTextBox1.AppendText("\n"+cellText);
}
}
//Thread.Sleep(15000);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
//Thread.Sleep(15000);
}
finally
{
con.Close();
}
우선, "읽기 위해 Excel 파일을 열고 클립 보드에 복사 ..."가 의미하는 바를 아는 것이 중요합니다.
의도하는 바에 따라 여러 가지 방법으로 수행 할 수 있기 때문에 이것은 매우 중요합니다. 설명하겠습니다.
데이터 세트를 읽고 클립 보드에 복사하고 데이터 형식 (예 : 열 이름)을 알고 있다면 OleDbConnection 을 사용하여 파일을 여는 것이 좋습니다. 이렇게 하면 xls 파일 내용을 데이터베이스로 처리 할 수 있습니다. 테이블, SQL 명령어로 데이터를 읽고 원하는대로 데이터를 처리 할 수 있습니다.
Excel 개체 모델을 사용하여 데이터에 대한 작업을 수행하려면 시작한 방식으로 엽니 다.
어떤 때는 xls 파일을 일종의 csv 파일 로 취급 할 수 있습니다. 임의의 개체에 구조를 매핑하여 xls 파일을 간단한 방법으로 처리하고 열 수있는 파일 도우미 와 같은 도구가 있습니다 .
또 다른 중요한 점은 파일의 Excel 버전입니다.
불행히도 저는 응용 프로그램 자동화, 데이터 관리 및 플러그인과 같은 개념에 국한된 경우에도 모든 방식으로 Office 자동화를 사용한 강력한 경험을 가지고 있으며 일반적으로 Excel 자동화 또는 Office 자동화를 사용하여 데이터 읽기; 그 작업을 수행하는 더 좋은 방법이 없다면.
자동화 작업은 리소스 비용 측면에서 성능면에서 무거울 수 있으며, 예를 들어 보안 등과 관련된 다른 문제와 관련 될 수 있으며, 마지막으로 COM interop 작업은 "무료"가 아닙니다. 그래서 제 제안은 필요로하는 상황을 생각하고 분석 한 다음 더 나은 방법을 선택하는 것입니다.
try
{
DataTable sheet1 = new DataTable("Excel Sheet");
OleDbConnectionStringBuilder csbuilder = new OleDbConnectionStringBuilder();
csbuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
csbuilder.DataSource = fileLocation;
csbuilder.Add("Extended Properties", "Excel 12.0 Xml;HDR=YES");
string selectSql = @"SELECT * FROM [Sheet1$]";
using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(selectSql, connection))
{
connection.Open();
adapter.Fill(sheet1);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
이것은 나를 위해 일했습니다. 시도해보고 문의 사항이 있으면 알려주십시오.
OLEDB 연결을 사용하여 Excel 파일과 통신합니다. 더 나은 결과를 제공합니다
using System.Data.OleDb;
string physicalPath = "Your Excel file physical path";
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
String strNewPath = physicalPath;
String connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strNewPath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
String query = "SELECT * FROM [Sheet1$]"; // You can use any different queries to get the data from the excel sheet
OleDbConnection conn = new OleDbConnection(connString);
if (conn.State == ConnectionState.Closed) conn.Open();
try
{
cmd = new OleDbCommand(query, conn);
da = new OleDbDataAdapter(cmd);
da.Fill(ds);
}
catch
{
// Exception Msg
}
finally
{
da.Dispose();
conn.Close();
}
출력 데이터는 데이터에 쉽게 액세스 할 수있는 데이터 셋 개체를 사용하여 데이터 셋에 저장됩니다. 도움이 되었기를 바랍니다.
시스템에서 Excel이없는 Excel 파일 판독기 및 작성기
- NPOI u'r 프로젝트 용 dll을 다운로드하여 추가합니다 .
이 코드를 사용하여 Excel 파일을 읽습니다.
using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { XSSFWorkbook XSSFWorkbook = new XSSFWorkbook(file); } ISheet objxlWorkSheet = XSSFWorkbook.GetSheetAt(0); int intRowCount = 1; int intColumnCount = 0; for (; ; ) { IRow Row = objxlWorkSheet.GetRow(intRowCount); if (Row != null) { ICell Cell = Row.GetCell(0); ICell objCell = objxlWorkSheet.GetRow(intRowCount).GetCell(intColumnCount); }}
다음은 특정 탭 또는 시트 이름이있는 스프레드 시트를 처리하고이를 CSV와 같은 것으로 덤프하는 코드입니다. (쉼표 대신 파이프를 선택했습니다).
세포에서 값을 얻는 것이 더 쉬웠 으면 좋겠지 만, 이것이 우리가 붙어있는 것이라고 생각합니다. 이 코드의 대부분을 얻은 MSDN 문서를 참조하는 것을 볼 수 있습니다. 이것이 Microsoft가 권장하는 것입니다.
/// <summary>
/// Got code from: https://msdn.microsoft.com/en-us/library/office/gg575571.aspx
/// </summary>
[Test]
public void WriteOutExcelFile()
{
var fileName = "ExcelFiles\\File_With_Many_Tabs.xlsx";
var sheetName = "Submission Form"; // Existing tab name.
using (var document = SpreadsheetDocument.Open(fileName, isEditable: false))
{
var workbookPart = document.WorkbookPart;
var sheet = workbookPart.Workbook.Descendants<Sheet>().FirstOrDefault(s => s.Name == sheetName);
var worksheetPart = (WorksheetPart)(workbookPart.GetPartById(sheet.Id));
var sheetData = worksheetPart.Worksheet.Elements<SheetData>().First();
foreach (var row in sheetData.Elements<Row>())
{
foreach (var cell in row.Elements<Cell>())
{
Console.Write("|" + GetCellValue(cell, workbookPart));
}
Console.Write("\n");
}
}
}
/// <summary>
/// Got code from: https://msdn.microsoft.com/en-us/library/office/hh298534.aspx
/// </summary>
/// <param name="cell"></param>
/// <param name="workbookPart"></param>
/// <returns></returns>
private string GetCellValue(Cell cell, WorkbookPart workbookPart)
{
if (cell == null)
{
return null;
}
var value = cell.CellFormula != null
? cell.CellValue.InnerText
: cell.InnerText.Trim();
// If the cell represents an integer number, you are done.
// For dates, this code returns the serialized value that
// represents the date. The code handles strings and
// Booleans individually. For shared strings, the code
// looks up the corresponding value in the shared string
// table. For Booleans, the code converts the value into
// the words TRUE or FALSE.
if (cell.DataType == null)
{
return value;
}
switch (cell.DataType.Value)
{
case CellValues.SharedString:
// For shared strings, look up the value in the
// shared strings table.
var stringTable =
workbookPart.GetPartsOfType<SharedStringTablePart>()
.FirstOrDefault();
// If the shared string table is missing, something
// is wrong. Return the index that is in
// the cell. Otherwise, look up the correct text in
// the table.
if (stringTable != null)
{
value =
stringTable.SharedStringTable
.ElementAt(int.Parse(value)).InnerText;
}
break;
case CellValues.Boolean:
switch (value)
{
case "0":
value = "FALSE";
break;
default:
value = "TRUE";
break;
}
break;
}
return value;
}
서버 측 앱에서 Excel 파일을 읽는 데 권장되는 방법은 Open XML입니다.
링크 몇 개 공유-
https://msdn.microsoft.com/en-us/library/office/hh298534.aspx
https://msdn.microsoft.com/en-us/library/office/ff478410.aspx
https://msdn.microsoft.com/en-us/library/office/cc823095.aspx
public void excelRead(string sheetName)
{
Excel.Application appExl = new Excel.Application();
Excel.Workbook workbook = null;
try
{
string methodName = "";
Excel.Worksheet NwSheet;
Excel.Range ShtRange;
//Opening Excel file(myData.xlsx)
appExl = new Excel.Application();
workbook = appExl.Workbooks.Open(sheetName, Missing.Value, ReadOnly: false);
NwSheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
ShtRange = NwSheet.UsedRange; //gives the used cells in sheet
int rCnt1 = 0;
int cCnt1 = 0;
for (rCnt1 = 1; rCnt1 <= ShtRange.Rows.Count; rCnt1++)
{
for (cCnt1 = 1; cCnt1 <= ShtRange.Columns.Count; cCnt1++)
{
if (Convert.ToString(NwSheet.Cells[rCnt1, cCnt1].Value2) == "Y")
{
methodName = NwSheet.Cells[rCnt1, cCnt1 - 2].Value2;
Type metdType = this.GetType();
MethodInfo mthInfo = metdType.GetMethod(methodName);
if (Convert.ToString(NwSheet.Cells[rCnt1, cCnt1 - 2].Value2) == "fn_AddNum" || Convert.ToString(NwSheet.Cells[rCnt1, cCnt1 - 2].Value2) == "fn_SubNum")
{
StaticVariable.intParam1 = Convert.ToInt32(NwSheet.Cells[rCnt1, cCnt1 + 3].Value2);
StaticVariable.intParam2 = Convert.ToInt32(NwSheet.Cells[rCnt1, cCnt1 + 4].Value2);
object[] mParam1 = new object[] { StaticVariable.intParam1, StaticVariable.intParam2 };
object result = mthInfo.Invoke(this, mParam1);
StaticVariable.intOutParam1 = Convert.ToInt32(result);
NwSheet.Cells[rCnt1, cCnt1 + 5].Value2 = Convert.ToString(StaticVariable.intOutParam1) != "" ? Convert.ToString(StaticVariable.intOutParam1) : String.Empty;
}
else
{
object[] mParam = new object[] { };
mthInfo.Invoke(this, mParam);
NwSheet.Cells[rCnt1, cCnt1 + 5].Value2 = StaticVariable.outParam1 != "" ? StaticVariable.outParam1 : String.Empty;
NwSheet.Cells[rCnt1, cCnt1 + 6].Value2 = StaticVariable.outParam2 != "" ? StaticVariable.outParam2 : String.Empty;
}
NwSheet.Cells[rCnt1, cCnt1 + 1].Value2 = StaticVariable.resultOut;
NwSheet.Cells[rCnt1, cCnt1 + 2].Value2 = StaticVariable.resultDescription;
}
else if (Convert.ToString(NwSheet.Cells[rCnt1, cCnt1].Value2) == "N")
{
MessageBox.Show("Result is No");
}
else if (Convert.ToString(NwSheet.Cells[rCnt1, cCnt1].Value2) == "EOF")
{
MessageBox.Show("End of File");
}
}
}
workbook.Save();
workbook.Close(true, Missing.Value, Missing.Value);
appExl.Quit();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(ShtRange);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(NwSheet);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(workbook);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(appExl);
}
catch (Exception)
{
workbook.Close(true, Missing.Value, Missing.Value);
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
System.Runtime.InteropServices.Marshal.CleanupUnusedObjectsInCurrentContext();
}
}
//code for reading excel data in datatable
public void testExcel(string sheetName)
{
try
{
MessageBox.Show(sheetName);
foreach(Process p in Process.GetProcessesByName("EXCEL"))
{
p.Kill();
}
//string fileName = "E:\\inputSheet";
Excel.Application oXL;
Workbook oWB;
Worksheet oSheet;
Range oRng;
// creat a Application object
oXL = new Excel.Application();
// get WorkBook object
oWB = oXL.Workbooks.Open(sheetName);
// get WorkSheet object
oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWB.Sheets[1];
System.Data.DataTable dt = new System.Data.DataTable();
//DataSet ds = new DataSet();
//ds.Tables.Add(dt);
DataRow dr;
StringBuilder sb = new StringBuilder();
int jValue = oSheet.UsedRange.Cells.Columns.Count;
int iValue = oSheet.UsedRange.Cells.Rows.Count;
// get data columns
for (int j = 1; j <= jValue; j++)
{
oRng = (Microsoft.Office.Interop.Excel.Range)oSheet.Cells[1, j];
string strValue = oRng.Text.ToString();
dt.Columns.Add(strValue, System.Type.GetType("System.String"));
}
//string colString = sb.ToString().Trim();
//string[] colArray = colString.Split(':');
// get data in cell
for (int i = 2; i <= iValue; i++)
{
dr = dt.NewRow();
for (int j = 1; j <= jValue; j++)
{
oRng = (Microsoft.Office.Interop.Excel.Range)oSheet.Cells[i, j];
string strValue = oRng.Text.ToString();
dr[j - 1] = strValue;
}
dt.Rows.Add(dr);
}
if(StaticVariable.dtExcel != null)
{
StaticVariable.dtExcel.Clear();
StaticVariable.dtExcel = dt.Copy();
}
else
StaticVariable.dtExcel = dt.Copy();
oWB.Close(true, Missing.Value, Missing.Value);
oXL.Quit();
MessageBox.Show(sheetName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
//code for class initialize
public static void startTesting(TestContext context)
{
Playback.Initialize();
ReadExcel myClassObj = new ReadExcel();
string sheetName="";
StreamReader sr = new StreamReader(@"E:\SaveSheetName.txt");
sheetName = sr.ReadLine();
sr.Close();
myClassObj.excelRead(sheetName);
myClassObj.testExcel(sheetName);
}
//code for test initalize
public void runValidatonTest()
{
DataTable dtFinal = StaticVariable.dtExcel.Copy();
for (int i = 0; i < dtFinal.Rows.Count; i++)
{
if (TestContext.TestName == dtFinal.Rows[i][2].ToString() && dtFinal.Rows[i][3].ToString() == "Y" && dtFinal.Rows[i][4].ToString() == "TRUE")
{
MessageBox.Show(TestContext.TestName);
MessageBox.Show(dtFinal.Rows[i][2].ToString());
StaticVariable.runValidateResult = "true";
break;
}
}
//StaticVariable.dtExcel = dtFinal.Copy();
}
Bytescout 스프레드 시트를 사용하는 것이 좋습니다.
https://bytescout.com/products/developer/spreadsheetsdk/bytescoutspreadsheetsdk.html
Unity3D에서 Monodevelop으로 시도했는데 매우 간단합니다. 이 샘플 코드를 확인하여 라이브러리 작동 방식을 확인하십시오.
https://bytescout.com/products/developer/spreadsheetsdk/read-write-excel.html
참고 URL : https://stackoverflow.com/questions/657131/how-to-read-data-of-an-excel-file-using-c
'Programing' 카테고리의 다른 글
rxjs에서 Observable을 가져 오는 가장 좋은 방법 (0) | 2020.11.24 |
---|---|
Python에서 XML을 JSON으로 변환하는 방법은 무엇입니까? (0) | 2020.11.24 |
단위 테스트 ASP.Net MVC Authorize 특성으로 로그인 페이지로의 리디렉션 확인 (0) | 2020.11.24 |
라벨 태그에서 "for"는 무엇입니까? (0) | 2020.11.24 |
Android-브로드 캐스트 인 텐트 ACTION_SCREEN_ON / OFF 수신 방법 (0) | 2020.11.24 |