Beispiel #1
0
        /// <summary>
        /// 合并 按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_MergeHtmls_Click(object sender, EventArgs e)
        {
            if (this.HtmlFileList == null)
            {
                return;
            }

            string         hstr    = Properties.Resources.TemplateHtml;
            HtmlDataDrawer hdFirst = new HtmlDataDrawer(HtmlFileList[0].FullName);
            string         title   = hdFirst.HtmlDocTitle;

            title = title.Substring(0, title.LastIndexOf("_"));
            string baseName = Path.GetFileNameWithoutExtension(HtmlFileList[0].FullName);

            baseName = baseName.Substring(0, baseName.LastIndexOf("_"));
            string mergedFilePath = Path.Combine(Path.GetDirectoryName(HtmlFileList[0].FullName), baseName + "_Merged.html");

            string bodyStr = "";

            foreach (FileInfo fi in this.HtmlFileList)
            {
                HtmlDataDrawer hd = new HtmlDataDrawer(fi.FullName);
                bodyStr += hd.GetAllHtmlData();
            }
            hstr = hstr.Replace("%title%", title);
            hstr = hstr.Replace("%body%", bodyStr);
            File.WriteAllText(mergedFilePath, hstr, Encoding.UTF8);

            MessageBox.Show("完成");
        }
Beispiel #2
0
        private void btn_readHtml_Click(object sender, EventArgs e)
        {
            string filePath = this.tb_htmlPath2Split.Text;

            if (!File.Exists(filePath))
            {
                MessageBox.Show("文件不存在");
                return;
            }
            HtmlDataDrawer hd = new HtmlDataDrawer(filePath);

            lbl_TotalDivs.Text = hd.DivCount.ToString();
        }
Beispiel #3
0
        /// <summary>
        /// 导入 按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ImportText_Click(object sender, EventArgs e)
        {
            if (StaticValues.ExcelOperator == null || StaticValues.ExcelOperator.App.ActiveWorkbook == null)
            {
                MessageBox.Show("请先打开Excel...");
                return;
            }
            string htmlPath = tb_DataFile.Text;

            if (!File.Exists(htmlPath))
            {
                MessageBox.Show("请拖入数据文件...");
                return;
            }
            HtmlDataDrawer     hd     = new HtmlDataDrawer(htmlPath);
            List <CellSegment> csList = hd.DataMergeByCellPosition(hd.GetAllData(), cb_AddSpaceTail.Checked?" ":"");     //获取所有数据,并根据单元格归档

            //导入数据
            StaticValues.ExcelOperator.ImportData(csList);
            MessageBox.Show("完成");
        }
Beispiel #4
0
        private void btn_SplitHtml_Click(object sender, EventArgs e)
        {
            string filePath = this.tb_htmlPath2Split.Text;

            if (!File.Exists(filePath))
            {
                MessageBox.Show("文件不存在");
                return;
            }
            HtmlDataDrawer hd        = new HtmlDataDrawer(filePath);
            int            fileCount = Convert.ToInt32(tb_fileCount.Text);

            try
            {
                hd.SplitBySpecFileCount(fileCount);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            MessageBox.Show("完成");
        }