Browse Source

improve format, fix a output bug

Shenjian 7 năm trước cách đây
mục cha
commit
d030287d03

+ 25 - 2
TxtDictionary/ExcelTool.cs

@@ -19,6 +19,7 @@ namespace TxtDictionary
                 
                 for (int i = 0; i < list.Count; i++)
                 {
+                    st.Cells[x, y, x, 4].Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Dotted;
                     st.Cells[x, y].Value = list[i].Text;
                     foreach (var ms in list[i].Meanings)
                     {
@@ -44,10 +45,32 @@ namespace TxtDictionary
                     }
                 }
 
-                st.Select("A:D");
-                st.SelectedRange.AutoFitColumns();
+                st.Cells.AutoFitColumns();
+
+                st.Cells.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
+                st.Cells.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
+
+                st.Column(4).Style.WrapText = true;
+
+               
+                st.Column(4).Width = 55;
+                
                 st.Name = (list.Count / count) * count + 1 + "-" + ((list.Count / count) * count + (list.Count % count));
 
+
+                st.InsertRow(1, 1);
+                st.Cells[1, 1, 1, 4].Merge = true;
+                st.Cells[1, 1].Value = "单词表";
+                st.Cells[1, 1].Style.Font.Bold = true;
+                st.Cells[1, 1].Style.Font.Size = 24;
+
+
+                st.Column(1).Style.Font.Name = "Arial";
+                st.Column(2).Style.Font.Name = "Arial";
+                st.Column(3).Style.Font.Name = "Arial";
+                st.Column(4).Style.Font.Name = "微软雅黑";
+                st.Cells[1, 1].Style.Font.Name = "微软雅黑";
+
                 ep.SaveAs(new System.IO.FileInfo(fileName));
             }
         }

+ 28 - 12
TxtDictionary/Form1.Designer.cs

@@ -31,7 +31,6 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
             this.txt_result = new System.Windows.Forms.TextBox();
             this.progressBar1 = new System.Windows.Forms.ProgressBar();
-            this.label1 = new System.Windows.Forms.Label();
             this.btn_onlyword = new System.Windows.Forms.Button();
             this.lbl_n = new System.Windows.Forms.Label();
             this.txt_numberPerPage = new System.Windows.Forms.TextBox();
@@ -45,6 +44,8 @@
             this.btn_Stop = new System.Windows.Forms.Button();
             this.txt_messageBox = new System.Windows.Forms.TextBox();
             this.btn_QuickStart = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
             this.groupBox1.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -57,6 +58,7 @@
             this.txt_result.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
             this.txt_result.Size = new System.Drawing.Size(730, 428);
             this.txt_result.TabIndex = 4;
+            this.txt_result.Text = "在此处输入要添加的单词,每个单词之间用回车分隔";
             // 
             // progressBar1
             // 
@@ -65,15 +67,6 @@
             this.progressBar1.Size = new System.Drawing.Size(723, 23);
             this.progressBar1.TabIndex = 5;
             // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(223, 20);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(15, 16);
-            this.label1.TabIndex = 6;
-            this.label1.Text = "-";
-            // 
             // btn_onlyword
             // 
             this.btn_onlyword.Location = new System.Drawing.Point(14, 13);
@@ -169,7 +162,7 @@
             this.btn_Info.Location = new System.Drawing.Point(14, 103);
             this.btn_Info.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.btn_Info.Name = "btn_Info";
-            this.btn_Info.Size = new System.Drawing.Size(163, 31);
+            this.btn_Info.Size = new System.Drawing.Size(74, 31);
             this.btn_Info.TabIndex = 14;
             this.btn_Info.Text = "使用说明";
             this.btn_Info.UseVisualStyleBackColor = true;
@@ -207,11 +200,33 @@
             this.btn_QuickStart.UseVisualStyleBackColor = true;
             this.btn_QuickStart.Click += new System.EventHandler(this.btn_QuickStart_Click);
             // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(103, 103);
+            this.button1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(74, 31);
+            this.button1.TabIndex = 18;
+            this.button1.Text = "清空";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(223, 20);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(220, 17);
+            this.label1.TabIndex = 6;
+            this.label1.Text = "欢迎使用单词表制作工具--Grace定制版";
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1058, 576);
+            this.Controls.Add(this.button1);
             this.Controls.Add(this.btn_QuickStart);
             this.Controls.Add(this.txt_messageBox);
             this.Controls.Add(this.btn_Stop);
@@ -240,7 +255,6 @@
 
         private System.Windows.Forms.TextBox txt_result;
         private System.Windows.Forms.ProgressBar progressBar1;
-        private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Button btn_onlyword;
         private System.Windows.Forms.Label lbl_n;
         private System.Windows.Forms.TextBox txt_numberPerPage;
@@ -254,6 +268,8 @@
         private System.Windows.Forms.Button btn_Stop;
         private System.Windows.Forms.TextBox txt_messageBox;
         private System.Windows.Forms.Button btn_QuickStart;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Label label1;
     }
 }
 

+ 5 - 1
TxtDictionary/Form1.cs

@@ -102,7 +102,7 @@ namespace TxtDictionary
                 sbWords.AppendLine(item.ToString().Trim());
             }
             //写单词表
-            Save("有结果单词表", sbWords.ToString());
+            Save("已查的单词表", sbWords.ToString());
 
 
             this.progressBar1.Maximum = ms.Count;
@@ -243,5 +243,9 @@ namespace TxtDictionary
 
         }
 
+        private void button1_Click(object sender, EventArgs e)
+        {
+            txt_result.Text = string.Empty;
+        }
     }
 }

BIN
TxtDictionary/bin/Debug/TxtDictionary.exe


+ 11 - 15
TxtDictionary/iciba.cs

@@ -44,32 +44,28 @@ namespace TxtDictionary
                 us = "";
             }
 
-
+            List<CixingChinese> cixings = new List<CixingChinese>();
             CixingChinese cixing = new CixingChinese();
             int counts = 0;
             try
             {
                 counts = doc.DocumentNode.SelectNodes("dict/pos").Count;
+                for (int i = 0; i < counts; i++)
+                {
+                    cixing = new CixingChinese();
+                    cixing.Cixing = doc.DocumentNode.SelectNodes("dict/pos")[i].InnerText;
+                    cixing.Cixing = cixing.Cixing.Replace("&amp;", "&");
+                    cixing.Chinese = doc.DocumentNode.SelectNodes("dict/acceptation")[i].InnerText;
+                    cixing.Chinese = cixing.Chinese.Replace("&lt;", "<").Replace("&gt;", ">");
+                    cixings.Add(cixing);
+                }
             }
             catch 
             {
+                return null;
                 cixing.Chinese = "";
                 cixing.Cixing = "";
             }
-
-            for (int i = 0; i < counts; i++)
-            {
-                cixing.Cixing = doc.DocumentNode.SelectNodes("dict/pos")[i].InnerText;
-                cixing.Cixing = cixing.Cixing.Replace("&amp;","&");
-                cixing.Chinese = doc.DocumentNode.SelectNodes("dict/acceptation")[i].InnerText;
-                cixing.Chinese = cixing.Chinese.Replace("&lt;", "<").Replace("&gt;", ">");
-
-            }
-
-            List<CixingChinese> cixings = new List<CixingChinese>();
-
-            cixings.Add(cixing);
-
             Meaning meaning = new Meaning(en, us, cixings);
             lm.Add(meaning);
             Word wordToReturn = new Word(wordText, lm);