我想使用webservice或httphandler提供大型Excel文件。
由于Excel文件的大小非常大,我想将它们拆分成较小的文件,以减少内存占用。
所以我将有一个包含列标题和数据的master excelfile。 以及仅包含数据的其他文件。
在下载过程中,我想首先流式传输主excel文件,然后将所有其他相关的Excel文件作为一个下载流附加。 我不想拉链它们!它应该是最后一个文件
这确实会回归废话:
void Main()
{
CombineMultipleFilesIntoSingleFile();
}
// Define other methods and classes here
private static void CombineMultipleFilesIntoSingleFile(string outputFilePath= @"C:\exceltest\main.xlsx", string inputDirectoryPath = @"C:\exceltest", string inputFileNamePattern="*.xlsx")
{
string[] inputFilePaths = Directory.GetFiles(inputDirectoryPath, inputFileNamePattern);
Console.WriteLine("Number of files: {0}.", inputFilePaths.Length);
using (var outputStream = File.Create(outputFilePath))
{
foreach (var inputFilePath in inputFilePaths)
{
using (var inputStream = File.OpenRead(inputFilePath))
{
// Buffer size can be passed as the second argument.
inputStream.CopyTo(outputStream);
}
Console.WriteLine("The file {0} has been processed.", inputFilePath);
}
}
}
答案 0 :(得分:2)
当您申请文件时,请不要在第一次请求时下载。
src
作为文件路径。当设置了iFrame的src
属性时,它将导航到文件路径,每个iFrame将下载单个文件,因此多个iFrame会下载多个文件。
您无法在单个请求中下载多个文件。好像你将附加多个文件的流,它将创建一个垃圾文件,一个垃圾文件。