예제 #1
0
        //private int GetFieldCount
        //{
        //    get { return _dsExecutedData.Tables[0].Columns.Count; }
        //}
        //private int GetRowCount
        //{
        //    get { return _dsExecutedData.Tables[0].Rows.Count; }
        //}

        private void ExportHtml()
        {
            Export.HtmlExportFormat format = new Export.HtmlExportFormat();
            format.FontColor = txtFontColor.Text;
            format.FontFamily = txtFontFamily.Text;
            format.FontSize = txtFontSize.Text;

            format.HeaderColor = txtHeaderBGColor.Text;
            format.RowAltColor = txtRowBgAltColor.Text;
            format.RowColor = txtRowBgcolor.Text;

            Export.HtmlExport.OnWrittenData += CSVExport_OnWrittenData;
            Export.HtmlExport.ExportToHTML(_dsExecutedData.Tables[0], txtFilePath.Text, format);

            #region Not used

            //StringBuilder sbCss = new StringBuilder();
            //StringBuilder sbHtml = new StringBuilder();
            //bool isAltSet = false;

            //sbCss.Append("<style>");
            //sbCss.Append("body { font-family:" + this.txtFontFamily.Text + "; font-size:" + this.txtFontSize.Text + "; color:" + this.txtFontColor.Text + "; }");
            //sbCss.Append(".Header {background-color:" + this.txtHeaderBGColor.Text + "}");
            //sbCss.Append(".Row    {background-color:" + this.txtRowBgcolor.Text + "}");
            //sbCss.Append(".AltRow    {background-color:" +  this.txtRowBgAltColor.Text + "}");
            //sbCss.Append("</style>");

            //this.SetStatusText = "Created style for html";

            //sbHtml.Append("<html>");
            //sbHtml.Append("<head><title>Export from " + _dsExecutedData.Tables[0].TableName + "</title>");
            //sbHtml.Append(sbCss.ToString());
            //sbHtml.Append("</head>");
            //sbHtml.Append("<body>");

            //int fields = this.GetFieldCount;
            //sbHtml.Append("<table border='0' cellpadding='2'");
            //sbHtml.Append("<tr>");
            //for (int i = 0; i < fields; i++)
            //{
            //    sbHtml.Append(string.Format("<td class='Header'>{0}</td>", _dsExecutedData.Tables[0].Columns[i].ColumnName));
            //    this.SetStatusText = "Writing column name " + i.ToString();
            //}
            //sbHtml.Append("</tr>");

            //int Counter = 0;
            //foreach (DataRow dr in _dsExecutedData.Tables[0].Rows)
            //{
            //    sbHtml.Append("<tr>");

            //    for (int i = 0; i < fields; i++)
            //    {
            //        if (isAltSet)
            //        {
            //            sbHtml.Append(string.Format("<td class='AltRow'>{0}</td>", dr[i].ToString()));

            //        }
            //        else
            //        {
            //            sbHtml.Append(string.Format("<td class='Row'>{0}</td>", dr[i].ToString()));

            //        }
            //    }
            //    Counter++;
            //    this.SetStatusText = "Wring row " + Counter.ToString();
            //    sbHtml.Append("</tr>");

            //    if (isAltSet == false)
            //        isAltSet = true;
            //    else
            //        isAltSet = false;
            //}
            //sbHtml.Append("</table>");
            //sbHtml.Append("</body></html>");


            //System.IO.TextWriter tw = new System.IO.StreamWriter(this.txtFilePath.Text);
            //tw.WriteLine(sbHtml.ToString());
            //tw.Close();
            //this.SetStatusText = "Finished exporting to html file"; 

            #endregion
        }
예제 #2
0
        public static void ExportToHTML(DataTable source, string fileName, HtmlExportFormat format)
        {
            StringBuilder sbCss = new StringBuilder();
            StringBuilder sbHtml = new StringBuilder();
            bool isAltSet = false;

            sbCss.Append("<style>");
            sbCss.Append("body { font-family:" + format.FontFamily + "; font-size:" + format.FontSize + "; color:" + format.FontColor + "; }");
            sbCss.Append(".Header {background-color:" + format.HeaderColor + "}");
            sbCss.Append(".Row    {background-color:" + format.RowColor + "}");
            sbCss.Append(".AltRow    {background-color:" + format.RowAltColor + "}");
            sbCss.Append("</style>");

            //this.SetStatusText = "Created style for html";

            sbHtml.Append("<html>");
            sbHtml.Append("<head><title>Export from " + source.TableName + "</title>");
            sbHtml.Append(sbCss.ToString());
            sbHtml.Append("</head>");
            sbHtml.Append("<body>");

            int fields = source.Columns.Count;
            sbHtml.Append("<table border='0' cellpadding='2'");
            sbHtml.Append("<tr>");
            for (int i = 0; i < fields; i++)
            {
                sbHtml.Append(string.Format("<td class='Header'>{0}</td>", source.Columns[i].ColumnName));

                if (OnWrittenData != null)
                {
                    OnWrittenData("Writing column name " + i);
                }
            }
            sbHtml.Append("</tr>");

            int counter = 0;
            foreach (DataRow dr in source.Rows)
            {
                sbHtml.Append("<tr>");

                for (int i = 0; i < fields; i++)
                {
                    if (isAltSet)
                    {
                        sbHtml.Append(string.Format("<td class='AltRow'>{0}</td>", dr[i]));
                    }
                    else
                    {
                        sbHtml.Append(string.Format("<td class='Row'>{0}</td>", dr[i]));
                    }
                }
                counter++;
                if (OnWrittenData != null)
                {
                    OnWrittenData("Writing row " + counter);
                }

                sbHtml.Append("</tr>");

                if (isAltSet == false)
                    isAltSet = true;
                else
                    isAltSet = false;
            }
            sbHtml.Append("</table>");
            sbHtml.Append("</body></html>");

            System.IO.TextWriter tw = new System.IO.StreamWriter(fileName);
            tw.WriteLine(sbHtml.ToString());
            tw.Close();
            if (OnWrittenData != null)
            {
                OnWrittenData("Finished exporting to html file");
            }
        }
예제 #3
0
        public static void ExportToHTML(DataTable source, string fileName, HtmlExportFormat format)
        {
            StringBuilder sbCss    = new StringBuilder();
            StringBuilder sbHtml   = new StringBuilder();
            bool          isAltSet = false;

            sbCss.Append("<style>");
            sbCss.Append("body { font-family:" + format.FontFamily + "; font-size:" + format.FontSize + "; color:" + format.FontColor + "; }");
            sbCss.Append(".Header {background-color:" + format.HeaderColor + "}");
            sbCss.Append(".Row    {background-color:" + format.RowColor + "}");
            sbCss.Append(".AltRow    {background-color:" + format.RowAltColor + "}");
            sbCss.Append("</style>");

            //this.SetStatusText = "Created style for html";

            sbHtml.Append("<html>");
            sbHtml.Append("<head><title>Export from " + source.TableName + "</title>");
            sbHtml.Append(sbCss.ToString());
            sbHtml.Append("</head>");
            sbHtml.Append("<body>");

            int fields = source.Columns.Count;

            sbHtml.Append("<table border='0' cellpadding='2'");
            sbHtml.Append("<tr>");
            for (int i = 0; i < fields; i++)
            {
                sbHtml.Append(string.Format("<td class='Header'>{0}</td>", source.Columns[i].ColumnName));

                if (OnWrittenData != null)
                {
                    OnWrittenData("Writing column name " + i);
                }
            }
            sbHtml.Append("</tr>");

            int counter = 0;

            foreach (DataRow dr in source.Rows)
            {
                sbHtml.Append("<tr>");

                for (int i = 0; i < fields; i++)
                {
                    if (isAltSet)
                    {
                        sbHtml.Append(string.Format("<td class='AltRow'>{0}</td>", dr[i]));
                    }
                    else
                    {
                        sbHtml.Append(string.Format("<td class='Row'>{0}</td>", dr[i]));
                    }
                }
                counter++;
                if (OnWrittenData != null)
                {
                    OnWrittenData("Writing row " + counter);
                }

                sbHtml.Append("</tr>");

                if (isAltSet == false)
                {
                    isAltSet = true;
                }
                else
                {
                    isAltSet = false;
                }
            }
            sbHtml.Append("</table>");
            sbHtml.Append("</body></html>");


            System.IO.TextWriter tw = new System.IO.StreamWriter(fileName);
            tw.WriteLine(sbHtml.ToString());
            tw.Close();
            if (OnWrittenData != null)
            {
                OnWrittenData("Finished exporting to html file");
            }
        }
예제 #4
0
        //private int GetFieldCount
        //{
        //    get { return _dsExecutedData.Tables[0].Columns.Count; }
        //}
        //private int GetRowCount
        //{
        //    get { return _dsExecutedData.Tables[0].Rows.Count; }
        //}
        private void ExportHtml()
        {
            Export.HtmlExportFormat format = new Export.HtmlExportFormat();
            format.FontColor = txtFontColor.Text;
            format.FontFamily = txtFontFamily.Text;
            format.FontSize = txtFontSize.Text;

            format.HeaderColor = txtHeaderBGColor.Text;
            format.RowAltColor = txtRowBgAltColor.Text;
            format.RowColor = txtRowBgcolor.Text;

            Export.HtmlExport.OnWrittenData += CSVExport_OnWrittenData;
            Export.HtmlExport.ExportToHTML(_dsExecutedData.Tables[0], txtFilePath.Text, format);

            #region Not used

            //StringBuilder sbCss = new StringBuilder();
            //StringBuilder sbHtml = new StringBuilder();
            //bool isAltSet = false;

            //sbCss.Append("<style>");
            //sbCss.Append("body { font-family:" + this.txtFontFamily.Text + "; font-size:" + this.txtFontSize.Text + "; color:" + this.txtFontColor.Text + "; }");
            //sbCss.Append(".Header {background-color:" + this.txtHeaderBGColor.Text + "}");
            //sbCss.Append(".Row    {background-color:" + this.txtRowBgcolor.Text + "}");
            //sbCss.Append(".AltRow    {background-color:" +  this.txtRowBgAltColor.Text + "}");
            //sbCss.Append("</style>");

            //this.SetStatusText = "Created style for html";

            //sbHtml.Append("<html>");
            //sbHtml.Append("<head><title>Export from " + _dsExecutedData.Tables[0].TableName + "</title>");
            //sbHtml.Append(sbCss.ToString());
            //sbHtml.Append("</head>");
            //sbHtml.Append("<body>");

            //int fields = this.GetFieldCount;
            //sbHtml.Append("<table border='0' cellpadding='2'");
            //sbHtml.Append("<tr>");
            //for (int i = 0; i < fields; i++)
            //{
            //    sbHtml.Append(string.Format("<td class='Header'>{0}</td>", _dsExecutedData.Tables[0].Columns[i].ColumnName));
            //    this.SetStatusText = "Writing column name " + i.ToString();
            //}
            //sbHtml.Append("</tr>");

            //int Counter = 0;
            //foreach (DataRow dr in _dsExecutedData.Tables[0].Rows)
            //{
            //    sbHtml.Append("<tr>");

            //    for (int i = 0; i < fields; i++)
            //    {
            //        if (isAltSet)
            //        {
            //            sbHtml.Append(string.Format("<td class='AltRow'>{0}</td>", dr[i].ToString()));

            //        }
            //        else
            //        {
            //            sbHtml.Append(string.Format("<td class='Row'>{0}</td>", dr[i].ToString()));

            //        }
            //    }
            //    Counter++;
            //    this.SetStatusText = "Wring row " + Counter.ToString();
            //    sbHtml.Append("</tr>");

            //    if (isAltSet == false)
            //        isAltSet = true;
            //    else
            //        isAltSet = false;
            //}
            //sbHtml.Append("</table>");
            //sbHtml.Append("</body></html>");

            //System.IO.TextWriter tw = new System.IO.StreamWriter(this.txtFilePath.Text);
            //tw.WriteLine(sbHtml.ToString());
            //tw.Close();
            //this.SetStatusText = "Finished exporting to html file";

            #endregion
        }