예제 #1
0
파일: TasksDAO.cs 프로젝트: wowsianka/IO
        public static Dictionary <int, int[]> GetTasks(string path)
        {
            Excel.Application excelApp       = new Excel.Application();
            Excel.Workbook    excelWorkbook  = excelApp.Workbooks.Open(path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            Excel.Worksheet   excelWorksheet = (Excel.Worksheet)excelWorkbook.Sheets[1];

            Excel.Range excelRange = excelWorksheet.Range["A2", "K51"];
            int         rows       = excelRange.Rows.Count;
            int         cols       = excelRange.Columns.Count;

            Object[,] values = (Object[, ])excelRange.Cells.Value;

            Dictionary <int, int[]> dictionary = new Dictionary <int, int[]>();

            for (int i = 0; i < rows; i++)
            {
                int[] times  = new int[rows - 1];
                int   taskID = Convert.ToInt32(values.GetValue(i + 1, 1));
                for (int j = 0; j < cols; j++)
                {
                    times[j] = Convert.ToInt32(values.GetValue(i + 1, j + 1));
                }
                dictionary.Add(taskID, times);
            }


            excelWorkbook.Close();
            excelApp.Quit();

            return(dictionary);
        }
예제 #2
0
        private string GetCellValue(Object[,] arry, int row, int col)
        {
            object o = arry.GetValue(row, col);

            if (o == null || o is DBNull || o.Equals(""))
            {
                return("");
            }
            return(o.ToString());
        }