Solved

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

Posted on 2006-11-22
13
699 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Installer 5 47
Two wordpress questions 3 78
Background video not displaying in Internet Explorer. 3 44
Drop Down not working in mobile- Bootstrap 14 32
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
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…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

749 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