Excel电子表格生成导致“不同于扩展错误的文件格式” 2007年开业时 [英] Excel spreadsheet generation results in "different file format than extension error" when opening in excel 2007

查看:169
本文介绍了Excel电子表格生成导致“不同于扩展错误的文件格式” 2007年开业时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

电子表格仍然显示,但带有警告消息。问题似乎是因为Excel 2007比早期版本的Excel更符合其扩展名。



问题最初由ASP.Net程序发现,并生成在Excel错误您尝试打开的文件中,Spreadsheet.aspx-18.xls的格式与文件扩展名指定的格式不同。验证...,但是当我打开文件时它显示的很好,我使用Excel 2007. Firefox将该文件标识为Excel 97-2003工作表。



这是一个产生问题的ASP.NET页面:

 <%@ Page Language =C#AutoEventWireup = trueCodeFile =Spreadsheet.aspx.csInherits =Spreadsheet%> 

代码后面的文件看起来像:

  public partial class Spreadsheet:System.Web.UI.Page {
protected void Page_Load对象发件人,EventArgs e)
{
Response.ContentType =application / vnd.ms-excel;
Response.Clear();
Response.Write(Field\\ \\ tValue\tCount\\\
);

Response.Write(Coin\PPenny\t443\\\
);
Response.Write(Coin\tNickel \t99\\\
);

}

}

T

解决方案

http://blogs.msdn。 com / vsofficedeveloper / pages / Excel-2007-Extension-Warning.aspx



这是一个基本上描述MS知道你所描述的问题的链接,它不能从ASP.NET代码中被抑制。它必须在客户端注册表上被禁止/修复。


The spreadsheet still displays, but with the warning message. The problem seems to occur because Excel 2007 is more picky about formats matching their extensions than earlier versions of Excel.

The problem was initially discovered by an ASP.Net program and produces in the Excel error "The file you are trying to open, "Spreadsheet.aspx-18.xls', is in a different format than specified by the file extension. Verify ...". However, when I open the file it displays just fine. I am using Excel 2007. Firefox identifies the file as an Excel 97-2003 worksheet.

Here is an ASP.NET page which generates the problem:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Spreadsheet.aspx.cs" Inherits="Spreadsheet" %>

The code behind file looks like:

public partial class Spreadsheet : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "application/vnd.ms-excel";
        Response.Clear();
        Response.Write("Field\tValue\tCount\n");

        Response.Write("Coin\tPenny\t443\n");
        Response.Write("Coin\tNickel\t99\n"); 

    } 

}

T

解决方案

http://blogs.msdn.com/vsofficedeveloper/pages/Excel-2007-Extension-Warning.aspx

That is a link basically describing that MS knows about the problem your describe and that it cannot be suppressed from within ASP.NET code. It must be suppressed/fixed on the client's registry.

这篇关于Excel电子表格生成导致“不同于扩展错误的文件格式” 2007年开业时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆