64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using Aspose.Cells;
|
|
|
|
namespace Server.Git
|
|
{
|
|
class ExcelManager
|
|
{
|
|
Dictionary<int, Dictionary<int, List<string>>> _dicViewer;
|
|
string _pathFile;
|
|
public ExcelManager(string path, string file)
|
|
{
|
|
_pathFile = path + "\\" + file;
|
|
Console.WriteLine(_pathFile);
|
|
_dicViewer = new Dictionary<int, Dictionary<int, List<string>>>();
|
|
}
|
|
public Dictionary<int, Dictionary<int, List<string>>> dicViewerOut
|
|
{
|
|
get { return _dicViewer; }
|
|
}
|
|
|
|
public void Play()
|
|
{
|
|
ExcelLoad(_pathFile);
|
|
}
|
|
public bool ExcelLoad(string path)//엑셀 로드
|
|
{
|
|
// 엑셀 파일 불러오기
|
|
Workbook wb = new Workbook(_pathFile);
|
|
|
|
// 모든 워크시트 가져오기
|
|
WorksheetCollection collection = wb.Worksheets;
|
|
|
|
// 모든 워크시트 반복
|
|
for (int worksheetIndex = 0; worksheetIndex < collection.Count; worksheetIndex++)
|
|
{
|
|
|
|
// 인덱스를 사용하여 워크시트 가져오기
|
|
Worksheet worksheet = collection[worksheetIndex];
|
|
|
|
// 워크시트 이름 인쇄
|
|
Console.WriteLine("Worksheet: " + worksheet.Name);
|
|
|
|
// 행과 열의 수 얻기
|
|
int rows = worksheet.Cells.MaxDataRow;
|
|
int cols = worksheet.Cells.MaxDataColumn;
|
|
|
|
// 행 반복
|
|
for (int i = 0; i < rows; i++)
|
|
{
|
|
|
|
// 선택한 행의 각 열 반복
|
|
for (int j = 0; j < cols; j++)
|
|
{
|
|
// 프링 셀 값
|
|
Console.Write(worksheet.Cells[i, j].Value + " | ");
|
|
}
|
|
// 줄바꿈 인쇄
|
|
Console.WriteLine(" ");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|