コード例 #1
0
ファイル: AggregationExcel.cs プロジェクト: xuanphu026/XuanP
        private void SaveHeaderNameSetting()
        {
            listGeneralIndividual = new List <GeneralIndividualName>();

            // loop all row
            foreach (DataGridViewRow row in gridView.Rows)
            {
                // get value General
                int        generalColValue  = row.Cells[0].Value == null ? -1 : (int)row.Cells[0].Value;
                string     generalNameValue = row.Cells[1].FormattedValue.ToString().Trim();
                HeaderName hdGeneral        = new HeaderName(generalColValue, generalNameValue);

                // get value individual
                int        individualColValue  = row.Cells[2].Value == null ? -1 : (int)row.Cells[2].Value;
                string     individualNameValue = row.Cells[2].FormattedValue.ToString().Trim();
                HeaderName hdIndividual        = new HeaderName(individualColValue, individualNameValue);

                GeneralIndividualName item = new GeneralIndividualName(hdGeneral, hdIndividual);

                listGeneralIndividual.Add(item);
            }

            SettingHeaderName settingHeaderName = new SettingHeaderName(listHeaderNameGeneral, listHeaderNameIndividual, listGeneralIndividual);

            // convert to json
            string jsonData = JsonConvert.SerializeObject(settingHeaderName);

            // save json
            SaveFile(jsonData);
        }
コード例 #2
0
ファイル: GeneralImageFile.cs プロジェクト: xuanphu026/XuanP
        private List <HeaderName> GetListHeaderNameByFileName()
        {
            List <HeaderName> listHeaderName = new List <HeaderName>();

            using (var workBook = new XLWorkbook(txtExcelGeneral.Text.Trim()))
            {
                // creat worksheet
                var worksheet = workBook.Worksheet(1);

                // get all col used in worksheet
                var colUsed = worksheet.ColumnsUsed().Count();

                // loop get header name
                for (int i = 0; i < colUsed; i++)
                {
                    string headerName = common.GetValue(worksheet, 1, i + 1);

                    if (headerName != "")
                    {
                        HeaderName hdName = new HeaderName((i + 1), headerName);
                        listHeaderName.Add(hdName);
                    }
                }
            }

            return(listHeaderName);
        }
コード例 #3
0
ファイル: GeneralImageFile.cs プロジェクト: xuanphu026/XuanP
        private void SetupGridview()
        {
            // clear all col
            gridViewReflect.Columns.Clear();

            // fill datasource gridview
            gridViewReflect.DataSource = listHeaderNameExcel;

            // init item default
            List <HeaderName> _paths     = new List <HeaderName>();
            string            pathExtend = listImages[0].Replace(txtPathImgGeneral.Text, "");
            int _idx = txtPathImgGeneral.Text.Split(Path.DirectorySeparatorChar).Length - 1;

            pathExtend.Split(Path.DirectorySeparatorChar).ToList().ForEach(path =>
            {
                HeaderName hdName = new HeaderName();
                hdName.Column     = _idx;
                hdName.Name       = path;
                _idx++;
                _paths.Add(hdName);
            });
            HeaderName hdDefault = new HeaderName(-1, "Not used");

            _paths[0] = hdDefault;

            // init combobox cell
            DataGridViewComboBoxColumn comboHeaderIndividual = new DataGridViewComboBoxColumn();

            comboHeaderIndividual.HeaderText    = "Header Individual";
            comboHeaderIndividual.ValueMember   = "Column";
            comboHeaderIndividual.DisplayMember = "Name";
            comboHeaderIndividual.DataSource    = _paths;
            comboHeaderIndividual.DefaultCellStyle.NullValue = "Not used";
            comboHeaderIndividual.FlatStyle = FlatStyle.Flat;

            gridViewReflect.Columns.Add(comboHeaderIndividual);

            // changed header text
            gridViewReflect.Columns[1].HeaderText = "Header General";

            // set width column
            gridViewReflect.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            gridViewReflect.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            // disable edit cell
            gridViewReflect.Columns[0].ReadOnly = true;
            gridViewReflect.Columns[1].ReadOnly = true;

            // set visible col
            gridViewReflect.Columns[0].Visible = false;

            // set disable resize row height
            gridViewReflect.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            gridViewReflect.AllowUserToResizeRows = false;

            gridViewReflect.EditMode = DataGridViewEditMode.EditOnEnter;
        }
コード例 #4
0
ファイル: AggregationExcel.cs プロジェクト: xuanphu026/XuanP
        private int GetColumnNumberByHeaderName(string headerName, List <HeaderName> listHeaderName)
        {
            HeaderName hdName = listHeaderName.Where(p => p.Name == headerName).FirstOrDefault();

            if (hdName != null)
            {
                return(hdName.Column);
            }

            return(-1);
        }
コード例 #5
0
ファイル: AggregationExcel.cs プロジェクト: xuanphu026/XuanP
        private void SetupGridview()
        {
            // clear all col
            gridView.Columns.Clear();

            // fill datasource gridview
            gridView.DataSource = listHeaderNameGeneral;

            // add combobox
            List <HeaderName> _listHeaderNameIndividual = new List <HeaderName>();

            foreach (var item in listHeaderNameIndividual)
            {
                _listHeaderNameIndividual.Add(item);
            }

            // init item default
            HeaderName hdDefault = new HeaderName(-1, "Not used");

            _listHeaderNameIndividual.Insert(0, hdDefault);

            // init combobox cell
            DataGridViewComboBoxColumn comboHeaderIndividual = new DataGridViewComboBoxColumn();

            comboHeaderIndividual.HeaderText    = "Header Individual";
            comboHeaderIndividual.DataSource    = _listHeaderNameIndividual;
            comboHeaderIndividual.ValueMember   = "Column";
            comboHeaderIndividual.DisplayMember = "Name";
            comboHeaderIndividual.DefaultCellStyle.NullValue = "Not used";
            comboHeaderIndividual.FlatStyle = FlatStyle.Flat;

            gridView.Columns.Add(comboHeaderIndividual);

            // changed header text
            gridView.Columns[1].HeaderText = "Header General";

            // set width column
            gridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            gridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            // disable edit cell
            gridView.Columns[0].ReadOnly = true;
            gridView.Columns[1].ReadOnly = true;

            // set visible col
            gridView.Columns[0].Visible = false;

            // set disable resize row height
            gridView.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            gridView.AllowUserToResizeRows = false;

            gridView.EditMode = DataGridViewEditMode.EditOnEnter;
        }
コード例 #6
0
        private void BindDataSourceCombobox()
        {
            HeaderName hdName = new HeaderName(-1, "-- None -- ");

            listDateCols.Insert(0, hdName);

            cmbDateHeader1.DataSource    = GetNewList(listDateCols);
            cmbDateHeader1.DisplayMember = "Name";
            cmbDateHeader1.ValueMember   = "Column";

            cmbDateHeader2.DataSource    = GetNewList(listDateCols);
            cmbDateHeader2.DisplayMember = "Name";
            cmbDateHeader2.ValueMember   = "Column";

            // setup gridview
            SetupGridViewFilter();
        }
コード例 #7
0
        public void BindDataSourceCombobox()
        {
            HeaderName hdName = new HeaderName(-1, "-- None -- ");

            listDateCols.Insert(0, hdName);
            HeaderName hdName2 = new HeaderName(-1, "-- None -- ");

            listDateCols2.Insert(0, hdName2);

            filter1.DataSource    = listDateCols2;
            filter1.DisplayMember = "Name";
            filter1.ValueMember   = "Column";

            filter2.DataSource    = listDateCols;
            filter2.DisplayMember = "Name";
            filter2.ValueMember   = "Column";

            // Init data for combobox compare
            InitListCompares();
            // setup gridview
            SetupGridView();
        }
コード例 #8
0
ファイル: AggregationExcel.cs プロジェクト: xuanphu026/XuanP
        private List <HeaderName> GetListHeaderNameByFileName(string fileName, string workSheetName, int numRowHeader)
        {
            List <HeaderName> listHeaderName = new List <HeaderName>();

            try
            {
                using (var workBook = new XLWorkbook(fileName))
                {
                    // creat worksheet
                    var worksheet = workBook.Worksheet(workSheetName);

                    // get all col used in worksheet
                    var colUsed = worksheet.ColumnsUsed().Count();

                    // loop get header name
                    for (int i = 0; i < colUsed; i++)
                    {
                        string headerName = common.GetValue(worksheet, numRowHeader, i + 1);

                        if (headerName != "")
                        {
                            HeaderName hdName = new HeaderName((i + 1), headerName);
                            listHeaderName.Add(hdName);
                        }
                    }
                }

                isErrGetHeader = false;
                return(listHeaderName);
            }
            catch (Exception)
            {
                isErrGetHeader = true;
                return(listHeaderName);

                throw;
            }
        }
コード例 #9
0
ファイル: AggregationExcel.cs プロジェクト: xuanphu026/XuanP
 public GeneralIndividualName(HeaderName nameGeneral, HeaderName nameIndividual)
 {
     NameGeneral    = nameGeneral;
     NameIndividual = nameIndividual;
 }