Ejemplo n.º 1
0
        private DataTable GetDataTable(Worksheet item, string range)
        {
            ExcelDataSource Eds = new ExcelDataSource();

            Eds.Name     = item.Name;
            Eds.FileName = @FileName;
            ExcelWorksheetSettings worksheetsetting = new ExcelWorksheetSettings(Eds.Name, range);

            Eds.SourceOptions = new ExcelSourceOptions(worksheetsetting);

            Eds.SourceOptions.SkipEmptyRows       = false;
            Eds.SourceOptions.UseFirstRowAsHeader = true;
            Eds.Fill();

            DataTable dt = ExcelDataSourceExtension.ToDataTable(Eds);

            dt.TableName = item.Name;

            return(dt);
        }
Ejemplo n.º 2
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string filename = "";

            splashScreenManager1.SplashFormStartPosition = DevExpress.XtraSplashScreen.SplashFormStartPosition.Default;


            try
            {
                filename = CUtil.LoadExcel(spread1);
                splashScreenManager1.ShowWaitForm();
                IWorkbook workbook = spread1.Document;


                foreach (Worksheet item in workbook.Worksheets)
                {
                    int nRow = item.GetUsedRange().RowCount;


                    IEnumerable <Cell> searchResult = ExcelDataSourceExtension.FindCell(item, "측점");

                    string strPos2;
                    string strPos1;
                    string strPos3;

                    foreach (Cell cell in searchResult)
                    {
                        if (cell.ColumnIndex != 1)
                        {
                            continue;
                        }

                        CPipeData Data = new CPipeData();
                        Data.SheetName     = item.Name;
                        Data.Data1Position = "B3:AN3";
                        Data.Data1RowIndex = 2;

                        Data.Data3Position = "AQ3:AR3";
                        Data.Data3RowIndex = 2;

                        strPos1 = string.Format("{0}{1}:{2}{3}", "B", 3, "AN", cell.RowIndex - 1);
                        strPos3 = string.Format("{0}{1}:{2}{3}", "AT", 3, "AW", cell.RowIndex - 1);
                        if (nRow == cell.RowIndex + 1)
                        {
                            strPos2 = string.Format("{0}{1}:{2}{3}", "B", cell.RowIndex + 1, "H", nRow);
                        }
                        else
                        {
                            strPos2 = string.Format("{0}{1}:{2}{3}", "B", cell.RowIndex + 1, "H", nRow - 1);
                        }



                        // = string.Format("{0}{1}:{2}{3}", "AQ", 3, "AR", nRow - 1);
                        Data.Data2Position = strPos2;
                        Data.Data2RowIndex = cell.RowIndex;

                        Data.Data1 = ExcelDataSourceExtension.ExcelToDataSource(filename, item, strPos1);
                        Data.Data2 = ExcelDataSourceExtension.ExcelToDataSource(filename, item, strPos2);
                        DataTable extend = ExcelDataSourceExtension.ExcelToDataSource(filename, item, strPos3);
                        SetExtend(Data.Data1, extend);
                        // Data.Data3 = GetDataTable(item, strPos3);
                        //Data.ManholeDt = GetManholeData1(Data.Data1);


                        PipeMngr.Add(Data);
                    }
                }

                int nCnt = PipeMngr.Data.Count;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                splashScreenManager1.CloseWaitForm();
            }
        }
Ejemplo n.º 3
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            string filename = "";

            splashScreenManager1.SplashFormStartPosition = DevExpress.XtraSplashScreen.SplashFormStartPosition.Default;


            try
            {
                filename = CUtil.LoadExcel(spread3);

                IWorkbook workbook = spread3.Document;

                splashScreenManager1.ShowWaitForm();
                foreach (Worksheet item in workbook.Worksheets)
                {
                    int nRow = item.GetUsedRange().RowCount;


                    IEnumerable <Cell> searchResult = ExcelDataSourceExtension.FindCell(item, "NO");

                    string strPos2;
                    string strPos1;
                    string strPos3;

                    foreach (Cell cell in searchResult)
                    {
                        if (cell.ColumnIndex != 1)
                        {
                            continue;
                        }

                        CMassData Data = new CMassData();
                        Data.SheetName = item.Name;

                        string strPos;


                        strPos1 = string.Format("{0}{1}:{2}{3}", "B", 1, "T", nRow);

                        Data.Data = ExcelDataSourceExtension.ExcelToDataSource(filename, item, strPos1);

                        /*
                         * 토적 데이터가 측점으로 정렬이 안 되어 있음
                         */
                        if (Data.SheetName == "DE")
                        {
                            string aaa = "aaaa";
                        }
                        DataTable sortTable = 토적정렬(Data.Data);
                        Data.Data = sortTable;

                        MassMngr.Add(Data);
                    }
                }

                int nCnt = MassMngr.Data.Count;

                MakeBaseData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                splashScreenManager1.CloseWaitForm();
            }
        }