c# - 在手机上打开 Excel 文件 (.xls) 时遇到问题
问题描述
我正在 Web 表单页面中创建一个 excel 文档,当我加载该页面时,系统会提示我下载一个可以在我的计算机上正常打开的 excel 文件。但是,如果我将相同的文件作为附件发送并尝试在手机上查看它,我会收到一条错误消息,指出文件格式不受支持。
这是我下面的代码..希望有人可以阐明....
我在手机上遇到的错误说:
文件读取错误。文件类型不受支持或文件已损坏。
excelling.aspx 代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="excelling.aspx.cs" Inherits="app_Files_excelling" %>
<html>
<head runat="server">
<title></title>
</head>
<body>
<p runat="server" id="p1">Hello world.</p>
<table>
<thead>
<tr>
<th>column 1 header</th>
<th>column 2 header</th>
</tr>
</thead>
<tbody>
<tr>
<td>column 1 value</td>
<td>column 2 value</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Footer 1</td>
<td>Footer 2</td>
</tr>
</tfoot>
</table>
</body>
</html>
excelling.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class app_Files_excelling : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=NCR.xls");
}
}
解决方案
推荐阅读
- python - 如何从抓取的数据中删除字符为 '\n' 和 'xa0' 但保留空格?
- amazon-web-services - 从 Lambda 在 Amplify 中访问 S3
- c# - 如何使用相同的 added_date 从 datagridview 计算总计列的总计?
- dart - 从可重用的小部件文本字段中检索数据
- excel - UDF - 如何将包含路径、工作簿名称、工作表名称和单元格引用的字符串转换为公式?
- reactjs - 根据先前的状态更改 Redux 中的状态
- jquery - Chart.render() 不是函数
- scrapy - 如何修复不同的元素文本以提取
- python - Pandas:从一系列数组创建新的数据框列
- vue.js - 第一次单击时提交状态为空白。Vuex