Пример #1
0
        private void LoadCSVFile()
        {
            var       CSVReader = new TableReader.CSVReader(_openFileDialogFileName);
            DataTable dt        = CSVReader.Read().Table;

            if (dt != null)
            {
                dgvCSVData.DataSource = dt;
                dgvSetting.DataSource = null;
                dgvSetting.Rows.Clear();
                dgvSetting.Columns.Clear();
                //
                string colCSVFileField_Name = "CSV File Field";
                string colFieldType_Name    = "CSV File Field Type";
                string colFieldType_Field   = "Field";
                string colFieldType_Entity  = "Entity";
                dgvSetting.Columns.Add(colCSVFileField_Name, colCSVFileField_Name);
                dgvSetting.Columns[colCSVFileField_Name].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                //
                DataGridViewComboBoxColumn dgvCmbCSVFileFieldType = new DataGridViewComboBoxColumn();
                dgvCmbCSVFileFieldType.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dgvCmbCSVFileFieldType.HeaderText   = colFieldType_Name;
                dgvCmbCSVFileFieldType.Name         = colFieldType_Name;
                dgvCmbCSVFileFieldType.Items.Add(colFieldType_Field);
                dgvCmbCSVFileFieldType.Items.Add(colFieldType_Entity);
                dgvSetting.Columns.Add(dgvCmbCSVFileFieldType);
                //
                DataGridViewComboBoxColumn dgvCmbEntity = new DataGridViewComboBoxColumn();
                dgvCmbEntity.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dgvCmbEntity.HeaderText   = colFieldType_Entity;
                dgvCmbEntity.Name         = colFieldType_Entity;
                foreach (var logicalName in _allEntityLogicalNames)
                {
                    dgvCmbEntity.Items.Add(logicalName);
                }
                dgvSetting.Columns.Add(dgvCmbEntity);
                //
                dgvSetting.Rows.Add(dgvCSVData.Columns.Count);
                for (int i = 0; i < dgvCSVData.Columns.Count; i++)
                {
                    dgvSetting.Rows[i].Cells[colCSVFileField_Name].Value = dgvCSVData.Columns[i].Name;
                    dgvSetting.Rows[i].Cells[colFieldType_Name].Value    = dgvCmbCSVFileFieldType.Items[0];
                }
                //

                //
                for (int i = 0; i < dgvSetting.Columns.Count - 1; i++)
                {
                    dgvSetting.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
                dgvSetting.Columns[dgvSetting.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var excelReader = new TableReader.XMLReader(XLSMFilePath, "Foglio1");

            excelReader.Print();
            Console.ReadKey();

            excelReader = new TableReader.XMLReader(XLSXFilePath, "Foglio1");
            excelReader.Print();
            Console.ReadKey();

            excelReader = new TableReader.XMLReader(@"c:\", "Foglio1");
            excelReader.Print();
            Console.ReadKey();

            excelReader = new TableReader.XMLReader(CiaoFilePath, "Foglio1");
            excelReader.Print();
            Console.ReadKey();

            var CSVReader = new TableReader.CSVReader(CSVFilePath);

            CSVReader.Print();
            Console.ReadKey();
        }