Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
 
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        M_setHtml();
     // GenerateMsWordDoc();
    }
 
    private void M_setHtml()
    {
        String _mainhtml = String.Empty;
        String _htmlhead = String.Empty;
        String _htmlfooter = String.Empty;
 
        String _html = String.Empty;
        ArrayList arrValues = new ArrayList(4);
 
        Int32 _index = 1;
        for (int i = 0; i < 2; i++)
        {
            //arrValues.Add(i.ToString());
          // _mainhtml = "";
            _htmlhead = "";
            _html = "";
            _htmlfooter = "";
            _index = 1;
            _htmlhead += "<table width='100%'  >";
            _htmlhead += "<tr> <td colspan='3'><b> Demo Doc</b></td></tr>";
            _htmlhead += "<tr> <td>Head 1</td> <td>Head 2</td> <td>Head 3</td></tr>";
            _htmlhead += "<tr> <td valign='top'>Tajuk Kurus</td> <td valign='top' colspan='2' >Tajuk Kurus</td> </tr>";
            _htmlhead += "<tr><td valign='top'>Tarkish</td> <td valign='top' colspan='2' >Tarkish</td> </tr>";
            _htmlhead += "<tr> <td colspan='3' ></td></tr>";
            _htmlhead += "<tr> <td colspan='3' ><table width='100%'> ";
 

            _htmlfooter += "<tr> <td colspan='3'><b> Footer Doc</b></td></tr>";
            _htmlfooter += "<tr> <td>Head 1</td> <td>Footer 2</td> <td>Footer 3</td></tr>";
            _htmlfooter += "<tr> <td valign='top'>Footer Kurus</td> <td valign='top' colspan='2' >Tajuk Kurus</td> </tr>";
            _htmlfooter += "<tr><td valign='top'>Footer</td> <td valign='top' colspan='2' >Footer</td> </tr>";
            _htmlfooter += "<tr> <td colspan='3' ></td></tr>";
            _htmlfooter += "<tr> <td colspan='3' ></td></tr>";
            _htmlfooter += "<tr> <td colspan='3' ></td></tr>";
 

 
            for (int j = 0; j < 25; j++)
            {
 
                if (_index > 10)
                {
                    _mainhtml += _htmlhead + _html + "</table> </td></tr> " + _htmlfooter+"</table>";
                    _index = 0;
                    _html = "";
                }
                else
                {
                    _html += "<tr><td>" + _index.ToString() + "</td><td>Demo1</td><td>Demo 3</td><td>Demo 4</td></tr>";
                }
                _index = _index + 1;
            }
 

 
            if (_index < 10)
            {
                for (int j = 0; j < _index + 3; j++)
                {
                    _html += "<tr><td>--</td><td>Demo1</td><td>Demo 3</td><td>Demo 4</td></tr>";
                    //_index = _index + 1;
                }
                _mainhtml += _htmlhead + _html + "</table> </td></tr>" + _htmlfooter+"</table>";
            }
 
            tdmain.InnerHtml = _mainhtml;
 
        }
 

        // outerdt.DataSource = arrValues;
        //outerdt.DataBind();
        //for (int i = 0; i < 15; i++)
        //{
        //    _html += "<tr><td>" + i.ToString() + "</td><td>Demo1</td><td>Demo 3</td><td>Demo 4</td></tr>";
        //}
        //tdmain.InnerHtml ="<table width='100%'>"+ _html+"</table>";

    }
    protected void outerRep_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        ArrayList arrValues = new ArrayList(4);
        for (int i = 0; i < 15; i++)
        {
            arrValues.Add(i.ToString());
        }
        if (e.Item.ItemType == ListItemType.Item)
        {
            DataRowView drv = e.Item.DataItem as DataRowView;
            DataList innerDataList = e.Item.FindControl("innerDataList") as DataList;
            innerDataList.DataSource = arrValues;
            innerDataList.DataBind();
        }
    }
 

    protected void GenerateMsWordDoc()
    {
 
        //String strBody = tdmain.InnerHtml;

        String fileName = "MsWordSample.doc";
 
        // You can add whatever you want to add as the HTML and it will be generated as Ms Word docs

        Response.AppendHeader("Content-Type", "application/msword");
 
        Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
 
        Response.Write("");
 
    }
 
    protected void btnsend_Click(object sender, EventArgs e)
    {
       // String strBody = divReport.InnerHtml;
        //GenerateMsWordDoc();
    }
 
}
Posted 3-Oct-12 1:42am
Edited 3-Oct-12 1:52am
103.7K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 553
1 CPallini 470
2 Sergey Alexandrovich Kryukov 418
3 George Jonsson 231
4 Afzaal Ahmad Zeeshan 194
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,032
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100