コード例 #1
0
        private void btnSetting_Clicked(object sender, RoutedEventArgs e)
        {
            var panel = new HeaderPage();

            panel.IsNewFileMode = false;
            panel.refreshDislpay(data_.Headers);

            var pw = new PopupWindow(panel);

            pw.ResizeMode = ResizeMode.CanResize;
            pw.Owner      = Window.GetWindow(this);
            pw.Title      = string.Format("设置字段 -- {0}", filePath_);
            pw.MinWidth   = 600;
            pw.MinHeight  = 400;
            if (pw.ShowDialog() == true)
            {
                var headers = panel.Headers;

                var tmp = new TableExcelData(headers, new List <TableExcelRow>());
                var arr = headers.Select(a => data_.Headers.FindIndex(b => b.FieldName == a.FieldName)).ToArray();
                foreach (var row in data_.Rows)
                {
                    var trow = new TableExcelRow();
                    trow.StrList = arr.Select(idx => idx < 0 ? string.Empty : row.StrList[idx]).ToList();
                    tmp.Rows.Add(trow);
                }

                refreshUIByTableExcelData(tmp);
            }
        }
コード例 #2
0
        private void btnAddExcel_Clicked(object sender, RoutedEventArgs e)
        {
            var panel = new HeaderPage();

            panel.IsNewFileMode = true;
            panel.ExcelDir      = AppData.Config.ExcelDir;
            panel.refreshDislpay(new List <TableExcelHeader>()
            {
                new TableExcelHeader()
                {
                    FieldName = "Id",
                    FieldType = "int",
                    FieldDesc = "唯一Id索引",
                },
                new TableExcelHeader()
                {
                    FieldName = "KeyName",
                    FieldType = "string",
                    FieldDesc = "唯一Key索引",
                },
            });

            var pw = new PopupWindow(panel);

            pw.ResizeMode = ResizeMode.CanResize;
            pw.Owner      = Window.GetWindow(this);
            pw.Title      = string.Format("新建Excel表格");
            pw.MinWidth   = 600;
            pw.MinHeight  = 400;
            if (pw.ShowDialog() == true)
            {
                try
                {
                    TableExcelWriter.genExcel(new TableExcelData(panel.Headers, new List <TableExcelRow>()), panel.ExcelFullPath);
                    refreshExcelPath(AppData.Config.ExcelDir);
                    lv.selectItemByFullPath(panel.ExcelFullPath);
                }
                catch (System.Exception ex)
                {
                    this.ErrBox(ex.Message);
                }
            }
        }