相关疑难解决方法(0)

excel文件的内容类型是什么?

我希望网站上的excel文件在点击时在Excel中打开,不会保存在桌面上,或者在浏览器中嵌入打开等等.现在显然这一切都取决于每个用户的所有配置,但最好的内容类型是什么和其他设置,以实现大部分时间?

excel mime-types

441
推荐指数
3
解决办法
49万
查看次数

为excel文档设置mime类型

MS Excel具有以下观察到的MIME类型:

  • application/vnd.ms-excel (官方)
  • application/msexcel
  • application/x-msexcel
  • application/x-ms-excel
  • application/x-excel
  • application/x-dos_ms_excel
  • application/xls
  • application/x-xls
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (XLSX)

是否有任何一种适用于所有版本的类型?如果没有,我们是否需要response.setContentType()单独设置这些mime类型中的每一个?

此外,我们在应用程序中使用文件流来显示文档(不仅仅是excel - 任何类型的文档).这样做,如果用户选择保存文件,我们如何保留文件名 - 目前,呈现文件的servlet名称显示为默认名称.

excel mime content-type

340
推荐指数
5
解决办法
40万
查看次数

使用.NET,如何根据文件签名而不是扩展名找到文件的mime类型

我正在寻找一种简单的方法来获取文件扩展名不正确或没有给出的mime类型,类似于.Net中的这个问题.

c# mime mime-types

234
推荐指数
9
解决办法
21万
查看次数

正确的.mp4的mime类型

我有两个申请,如下所述:

  1. 管理员应用程序,通过它我可以将.mp4文件上传到服务器.
  2. 我想在iPad上使用移动应用程序下载.mp4.

  • Admin应用程序是使用asp.net 4.0和SQL Server,IIS7制作的.
  • 移动应用是由asp.net MVC3,jquerymobile,HTML5的.

截至目前,我已video/mp4在IIS7 mime类型部分中为.mp4 添加了mime类型.

当我试图在iPad下载.mp4文件时,我看到一个带有十字箭头的深黑色屏幕.任何人都可以帮我解决这个问题.

请告诉我video/mp4.mp4 的mime类型是否正确.

video html5-video mime-types

154
推荐指数
2
解决办法
19万
查看次数

如何为pdf,xlsx和txt文件android制作intent.setType?

我想从存储中仅选择pdf,xlsx和txt文件,但intent.setType只能执行一个文件(仅限eg.txt文件(或)pdf文件).是否可以通过编码intent.setType()来获取所有三个文件,并且有办法吗?

这是我的一些代码.

  private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("application/pdf");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        startActivityForResult(
                Intent.createChooser(intent, "Select txt file"),
                0);
    } catch (android.content.ActivityNotFoundException ex) {
        // Potentially direct the user to the Market with a Dialog

    }
}
Run Code Online (Sandbox Code Playgroud)

android android-intent

30
推荐指数
6
解决办法
4万
查看次数

使用PHPWord自动下载文件附件

我正在尝试使用PHPWord生成word文档.并且可以成功生成文档.但是有一个问题是我生成的word文档将保存在服务器上.我怎样才能立即下载?

样品:

$PHPWord = new PHPWord();
//Searching for values to replace
$document = $PHPWord->loadTemplate('doc/Temp1.docx');
$document->setValue('Name', $Name);
$document->setValue('No', $No);
$document->save('php://output'); //it auto save into my 'doc' directory.
Run Code Online (Sandbox Code Playgroud)

我如何链接到标题下载它如下:

header("Content-Disposition: attachment; filename='php://output'"); //not sure how to link this filename to the php://output..
Run Code Online (Sandbox Code Playgroud)

好心提醒.

php phpword

10
推荐指数
3
解决办法
3万
查看次数

如何在.NET Core中提供使用OpenXml创建的可下载excel文件

在此输入图像描述我在.NETCoreApp 1.1中使用OpenXml 2.7.2生成了一个excel文件,并将其保存到项目文件夹中.然后在我的函数中,我读取字节并尝试将其作为文件返回.我没有收到错误,但在回复中我只是得到了二进制文件.所以它似乎工作,但没有下载.

这是我的代码:

[HttpGet]
[Route("export")]
public IActionResult Export()
    {
        return File(System.IO.File.ReadAllBytes(filePath),
        contentType: "application/octet-stream",
        fileDownloadName: "MySheet.xlsx");

    }
Run Code Online (Sandbox Code Playgroud)

如果有人知道如何在.net核心中提供可下载的excel文件,请告诉我.任何帮助表示赞赏谢谢!

UPDATE

我不确定腐败是否与使用OpenXml生成excel文件有关,因为即使我尝试导出未使用OpenXml生成的空文件,我也会收到相同的错误消息"文件已损坏且无法打开" .它也与Excel 2016不完全相关,因为我可以打开其他excel文件.

download openxml export-to-excel .net-core

8
推荐指数
1
解决办法
389
查看次数

Angular 5下载带有帖子请求的excel文件

我正面临一个问题,我用Angular 1下载了一个Excel文件,但是如果我在Angular 5中实现了相同的代码,则会显示您的文件已损坏的错误.我的回复是在ArrayBuffer中,我无法读取该文件.

以下是我的代码:

服务:

 DownloadData(model:requiredParams):Observable<any>{
  const headers = new Headers();
  const requestOptions = new RequestOptions({ headers: headers });
  requestOptions.headers.append('Content-Type', 'application/json');

   const body = JSON.stringify(model);
  return this.http.post(url, body, requestOptions)
  .map((res:any) => res)
 .catch((e: any) => Observable.throw(this.errorHandler(e)));
 }
Run Code Online (Sandbox Code Playgroud)

零件:

exportToExcel() {
    this.loadingOverlayFlag = true;
   this.podashboardService.DownloadData(this.data).subscribe(result=>{
    console.log(result);
    this.downloadFile(result._body,'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'export.xlsx');
  })
  }

 downloadFile(blob: any, type: string, filename: string) {

 var binaryData = [];
   binaryData.push(blob);

     const url = window.URL.createObjectURL(new Blob(binaryData, {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})); // <-- work with blob directly

     // create hidden dom …
Run Code Online (Sandbox Code Playgroud)

angular-services angular

8
推荐指数
2
解决办法
8485
查看次数

如何通过android中的意图选择几种类型的文件?

我将选定的文件上传到服务器,但我知道我想restrick用户只选择文档文件(.doc,.pdf等)和图像文件.

现在我的代码适用于所有文件,它提取uri的所有文件,所以请告诉我如何限制用户只选择特定类型的文件.

这是我选择任何文件的代码.

Intent i=new Intent();
i.setType("*/*");
i.setAction(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(i, "abc"),requestCode);
Run Code Online (Sandbox Code Playgroud)

android file android-intent

7
推荐指数
2
解决办法
1万
查看次数

PHP强制下载.xlsx文件损坏

我正在开发一个允许教师上传文件和学生下载文件的网站。但是,有一个问题。Microsoft Word (.docx) 文件可以完美下载,但是在下载 excel (xlsx) 文件时,excel 会显示“此文件已损坏,无法打开”对话框。对此的任何帮助将不胜感激!

我的下载代码如下:

case 'xlsx':

    header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Pragma: no-cache');
    readfile('./uploads/resources/courses/' . $filename);

break;
Run Code Online (Sandbox Code Playgroud)

php header download readfile

6
推荐指数
1
解决办法
2万
查看次数