Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2004, 04:07 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to drumph Send a message via Yahoo to drumph
Default application/vnd.ms-excel Help!

I am having a problem with application/vnd.ms-excel.
The page displays a table with statistical information then at the
bottom of the page there is a link the generates a spreadsheet the with the same statistical information. The information is being passed to then next page just fine but it will not populate the tables in the spreadsheet.. This link has worked for at least 2 years now all of a sudden it will not generate the Spreadsheet.. The code has not changed but many of the client who connect to the pages not have XP. On the internet I have found the following code that should resolvethe problem:
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
EnableViewState = false

they emphasize the "EnableviewState = False" line.
With this code I get a little further but excel file name it
generates is the full http://jones?coins.asp&ftech=jones&...etc

Is there anyway to force the file name or does anyone have any
insight how I can get my page to generate the correct Excel
Spreadsheets..

All of a sudden application/vnd.ms-excel is not working. From all I have read it should be simple to generate a spreadsheet but I am not having any luck..
Help
Server is 2000, IIS, ASP 3.0


 
Old May 15th, 2004, 07:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

check out http://www.greggriffiths.org/webdev/both/excel/ which covers this in some detail with a variety of methods to achieve the end result.
 
Old May 15th, 2004, 08:53 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Drumph

Have you thought about creating a CSV file instead? CSV's are much more portable (not only insert into Exell but Databases etc) and are in effect the same as an .xls Once you import a csv into exell you can save it as what ever you like. Below is a working piece of code, there are obvious changes (DB connection, table names etc) - it works like a charm and yes you can specify a file name.
-----------------------------
<?
    if ($_GET['branch'] != "")
    {
          header("Content-Disposition: attachment; filename=branch.csv");
          include("scripts/auditdb.php");
          $errorList = array();
          $count = 0;

          if (sizeof($errorList) == 0)
          {
                //START FILLING IN THE FIELDNAME ON TOP OF EXCEL SHEET.
                $fieldSql = "SHOW FIELDS FROM sitedetails";
                $getFieldInfo = mysql_query($fieldSql);
                $i = 0;
                while ($row = mysql_fetch_array($getFieldInfo))
                {
                     echo $row['Field'] . ",";
                }
                echo ("\n");

                //START FILLING IN THE ROWS IN EXCEL SHEET.
                $sql = "SELECT * FROM sitedetails WHERE BSBCode = '".$_GET['bsb']."'";
                $getInfo = mysql_query($sql);
                while($row = mysql_fetch_array($getInfo, MYSQL_ASSOC))
                {
                  while (list($key, $value) = each($row))
                  {
                    echo ("$value" . ",");
                  }
                  echo ("\n");
                }
                mysql_close($conn);
           }
           else
           {
              listErrors();
           }
   }
   else
   {
      echo "need to pass QS values";
   }
?>
----------------------------------------------


Wind is your friend
Matt
 
Old May 31st, 2007, 06:02 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your filename can be manipulated by adding the header as per the two examples below. The 1st example just names it as standard, the second refers to a variable so you can name the file based on a dataset record.

Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader "Content-Disposition", "attachment; filename=Whatever.xls"
Dim Filename

FileName = objRSAll("FieldName") & "_Export"
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=" & FileName & ".xls"""





Similar Threads
Thread Thread Starter Forum Replies Last Post
"application/vnd.ms-excel" problem akeyworth Classic ASP Components 1 January 15th, 2008 01:09 PM
When I used "application/vnd.ms-excel" to export t miaomiaoga Classic ASP Basics 1 October 20th, 2007 04:00 AM
MS Data Grid control in ms access application roshla_p Access VBA 5 October 16th, 2006 02:37 AM
When I used "application/vnd.ms-excel" to export t miaomiaoga Classic ASP Databases 0 January 28th, 2005 04:12 PM
Using MS Excel in application justshahid VS.NET 2002/2003 2 January 13th, 2005 11:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.