C# DevExpressspreadsheetctrol의 기본 사용 방법 Excel 플러그인

2153 단어 DevExpress
 //  Excel
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (Convert.ToInt32(trv_menu.SelectedNode.Tag) == 0)
            {
                MessageBox.Show("      ", "    ", MessageBoxButtons.OK);
                return;
            }
            openFileDialog1.Filter = "*.xls|*.xlsx";
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            { 
                spreadsheetControl1.LoadDocument(openFileDialog1.FileName);
            }
            spreadsheetControl1.ReadOnly = false;
            //barButtonItem_Save.Visibility =DevExpress.XtraBars. BarItemVisibility.Always;
            barButtonItem_Save.Enabled = true;
        }
//  Excele  
  //      
            int rowCount = worksheet.Cells.CurrentRegion.RowCount;
            //      
            int columnCount = worksheet.Cells.CurrentRegion.ColumnCount;
            if (rowCount == 1 && columnCount == 1)
            { 
                MessageBox.Show("      ", "  ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            for (int i = 0; i < rowCount; i++)
            { 
                for (int j = 0; j < columnCount; j++)
                {
                    var cellValue = spreadsheetControl1.ActiveWorksheet.Cells[i, j].Value;
                 }
            }
//        Excel
        SetCellText(spreadsheetControl1.ActiveWorksheet, location, item.F_Name, true);
 /// 
        ///         Excel
        /// 
        /// 
        ///      A1 B2
        ///  
        ///     
        private void SetCellText(Worksheet workSheet, string coordinates, string coordValue, bool isBold)
        {
            workSheet.Cells[coordinates].Value = coordValue;
            workSheet.Cells[coordinates].Style.Font.Bold = isBold;
        }

좋은 웹페이지 즐겨찾기