Solved

CSS for an aspx page of (application/vnd.ms-excel)

Posted on 2006-11-22
13
694 Views
Last Modified: 2008-02-01
Experts;

I have an aspx page of content-type of application/vnd.ms-excel; I am displaying a Table in this page as an excel sheet

I need to format the display of this table (Color; Alignment; width,..etc) I tryed to use a css file but it is not working

any ideas??

Thanks
0
Comment
Question by:mmalaka
  • 6
  • 4
13 Comments
 
LVL 6

Expert Comment

by:bigphuckinglizard
ID: 18001907
you need to put the css styles inline in the head section e.g.

<html><head>
<title>Hello</title>
<style>
.red { color: red; font-size: 30px }
.blue { color: blue; font-weight: bold }
.green { color: green; text-decoration: underline }
</style>
</head>
<body>
<table>
<tr>
<td class="red">Red</td>
<td class="green">Red</td>
<td class="blue">Red</td>
</tr>
</table>
</body>
0
 

Author Comment

by:mmalaka
ID: 18002011

I tryed that already, but it is not working; I think coz I am building the HTML table at runtime

No It is not working :(

0
 
LVL 6

Expert Comment

by:bigphuckinglizard
ID: 18002015
i tested that and it works with excel 2003. post your code.
0
 

Author Comment

by:mmalaka
ID: 18002019
this is my HTML code

<%@ Page language="c#" Codebehind="Excel_Report.aspx.cs" AutoEventWireup="false" Inherits="Lgcsb.Gis.CB.Excel_Report" contentType="application/vnd.ms-excel" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
      <HEAD>
            <TITLE>QueryForm</TITLE>
            <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" Content="C#">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            
            <style>


.QueryForm
{
      border-right: black thin solid;
      table-layout: auto;
      border-top: black thin solid;
      border-left: black thin solid;
      border-bottom: black thin solid;
      border-collapse: collapse;
}

.header
{
      border-right: black thin;
      border-top: black thin;
      font-size: smaller;
      border-left: black thin;
      color: white;
      border-bottom: black thin;
      font-family: Verdana, Sans-Serif;
      background-color: #00659c;
      text-align: left;
}

.Address
{
      color: white;
      background-color: #8db6cc;
      text-align: left;
      font-size: smaller;
      font-family: Verdana, Sans-Serif;
      width:100%
}

.Address
{
      font-weight: bolder;
      font-size: smaller;
      width: 100%;
      color: white;
      font-family: Verdana, Sans-Serif;
      background-color: #8db6cc;
      text-align: center;
}

.goToMap
{
      width: 100%;
      cursor: hand;
      font-family: wingdings;
      text-align: center;
      
}

.ExpExcel
{
      font-weight: bold;
      font-size: x-small;
      width: 100%;
      cursor: hand;
      color: #0033cc;
      font-family: Verdana, Sans-Serif;
      text-align: center;
      text-decoration: underline;
}

.repTable TH
{
      font-weight: bold;
      font-size: smaller;
      color: #ffff66;
      font-family: Verdana, Sans-Serif;
      background-color: #00659c;
      text-align: left;
}
            
            </style>
      </HEAD>

      <body >
            </body>
</HTML>


0
 

Author Comment

by:mmalaka
ID: 18002034
the server code to build the table is as follows

            private void Page_Load(object sender, System.EventArgs e)
            {
                  Response.Write(Session["ExcelContents"].ToString().Replace("\"", "'"));
                  Response.End();
            }
Session["ExcelContents"] hold the follwoing value:

"<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" class=\"repTable\"><tr>\t<td class=\"Address\" colspan=\"3\">ded</td></tr><tr>\t<th>Map</th>\t<th>ID1</th></tr><tr>\t<td><span class=\"goToMap\" onclick=GoToInMap(\"6a0198225419492da7e27ed042df1847\",\"101\");>&#245;</span></td>\t<td>101</td>\t<td><input type=\"button\" value=\"more\" onclick=GetDetails(\"6a0198225419492da7e27ed042df1847\",\"101\"); /></td></tr></table><span style=\"width:100%;text-align:center;\"><< results 1 to 1 of 1 >></span>"
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 6

Expert Comment

by:bigphuckinglizard
ID: 18002042
what does the code for the entire generated xls file look like?
0
 

Author Comment

by:mmalaka
ID: 18002063
ok,,,

when I remove the content-type of application/vnd.ms-excel and regenrate the page again I got this when I view the source

<table cellpadding='0' cellspacing='0' border='1' class='repTable'><tr>      <td class='Address' colspan='3'>ded</td></tr><tr>      <th>Map</th>      <th>ID1</th></tr><tr>      <td><span class='goToMap' onclick=GoToInMap('6a0198225419492da7e27ed042df1847','101');>&#245;</span></td>      <td>101</td>      <td><input type='button' value='more' onclick=GetDetails('6a0198225419492da7e27ed042df1847','101'); /></td></tr></table><span style='width:100%;text-align:center;'><< results 1 to 1 of 1 >></span>





0
 

Author Comment

by:mmalaka
ID: 18002078
Ok

Just now I solve it

I added a PlaceHolder Control in the page so the HTML Page is now look like this

<%@ Page language="c#" Codebehind="Excel_Report.aspx.cs" AutoEventWireup="false" Inherits="Lgcsb.Gis.CB.Excel_Report"  contentType="application/vnd.ms-excel"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
      <HEAD>
            <TITLE>QueryForm</TITLE>
            <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" Content="C#">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <style>


.QueryForm { BORDER-RIGHT: black thin solid; TABLE-LAYOUT: auto; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid; BORDER-COLLAPSE: collapse }


.header { BORDER-RIGHT: black thin; BORDER-TOP: black thin; FONT-SIZE: smaller; BORDER-LEFT: black thin; COLOR: white; BORDER-BOTTOM: black thin; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #00659c; TEXT-ALIGN: left }


.Address { FONT-SIZE: smaller; WIDTH: 100%; COLOR: white; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #8db6cc; TEXT-ALIGN: left }


.Address { FONT-WEIGHT: bolder; FONT-SIZE: smaller; WIDTH: 100%; COLOR: white; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #8db6cc; TEXT-ALIGN: center }


.goToMap { WIDTH: 100%; CURSOR: hand; FONT-FAMILY: wingdings; TEXT-ALIGN: center }


.ExpExcel { FONT-WEIGHT: bold; FONT-SIZE: x-small; WIDTH: 100%; CURSOR: hand; COLOR: #0033cc; FONT-FAMILY: Verdana, Sans-Serif; TEXT-ALIGN: center; TEXT-DECORATION: underline }


.repTable TH { FONT-WEIGHT: bold; FONT-SIZE: smaller; COLOR: #ffff66; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #00659c; TEXT-ALIGN: left }


            </style>
      </HEAD>
      <body>
            <asp:placeholder id="phQueries" Runat="server"></asp:placeholder>
      </body>
</HTML>


and I use the following C# to upload the content of the report

phQueries.Controls.Add(new LiteralControl(Session["ExcelContents"].ToString().Replace("\"", "'")));
0
 
LVL 6

Expert Comment

by:bigphuckinglizard
ID: 18002098
why not just have a literal in the page and set the text property in the codebehind?
0
 

Author Comment

by:mmalaka
ID: 18186208
This is the Solution

<%@ Page language="c#" Codebehind="Excel_Report.aspx.cs" AutoEventWireup="false" Inherits="Lgcsb.Gis.CB.Excel_Report"  contentType="application/vnd.ms-excel"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
     <HEAD>
          <TITLE>QueryForm</TITLE>
          <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
          <meta name="CODE_LANGUAGE" Content="C#">
          <meta name="vs_defaultClientScript" content="JavaScript">
          <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
          <style>


.QueryForm { BORDER-RIGHT: black thin solid; TABLE-LAYOUT: auto; BORDER-TOP: black thin solid; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid; BORDER-COLLAPSE: collapse }


.header { BORDER-RIGHT: black thin; BORDER-TOP: black thin; FONT-SIZE: smaller; BORDER-LEFT: black thin; COLOR: white; BORDER-BOTTOM: black thin; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #00659c; TEXT-ALIGN: left }


.Address { FONT-SIZE: smaller; WIDTH: 100%; COLOR: white; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #8db6cc; TEXT-ALIGN: left }


.Address { FONT-WEIGHT: bolder; FONT-SIZE: smaller; WIDTH: 100%; COLOR: white; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #8db6cc; TEXT-ALIGN: center }


.goToMap { WIDTH: 100%; CURSOR: hand; FONT-FAMILY: wingdings; TEXT-ALIGN: center }


.ExpExcel { FONT-WEIGHT: bold; FONT-SIZE: x-small; WIDTH: 100%; CURSOR: hand; COLOR: #0033cc; FONT-FAMILY: Verdana, Sans-Serif; TEXT-ALIGN: center; TEXT-DECORATION: underline }


.repTable TH { FONT-WEIGHT: bold; FONT-SIZE: smaller; COLOR: #ffff66; FONT-FAMILY: Verdana, Sans-Serif; BACKGROUND-COLOR: #00659c; TEXT-ALIGN: left }


          </style>
     </HEAD>
     <body>
          <asp:placeholder id="phQueries" Runat="server"></asp:placeholder>
     </body>
</HTML>

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18200098
PAQed with points refunded (20)

Computer101
EE Admin
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about why website design really matters in today's demanding market.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now