Solved

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

Posted on 2006-11-22
13
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

690 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