?
Solved

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

Posted on 2006-11-22
13
Medium Priority
?
736 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
11 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
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 

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

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

How do you create a user-centered user experience on your website? And what are some things you should consider in the process?
Although a new technology, ReactJs offers multiple benefits to the website owners when it comes to creating interactive websites. Know what aspects make React Js one of the most popular frameworks for building websites.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

569 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