如何在一次点击中生成多个文件/账单? [英] How to generate multiple file/bill on single click ?
问题描述
大家好,
我有一个简单的方法,可以根据视图(Export.cshtml)生成文件以格式化数据.
Hi everyone,
I have a simple method wich generate a file based on a view (Export.cshtml) to format data.
//ExportController
public ActionResult Export(string searchString, int searchOrder = 0)
{
var user = from m in db.Orders select m;
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
return this.View(user);
}
在下面的代码中,我添加了一个if条件来选择一个clientID.
In the following code, I added a if condition to select a clientID.
//Index.cshtml
public ActionResult Export(string searchString, int searchOrder = 0)
{
var user = from m in db.Orders select m;
if (!String.IsNullOrEmpty(searchString))
{
user = user.Where(s => s.ClientID.Contains(searchString));
}
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
return this.View(user);
}
在这种情况下,我在Index.cshtml视图中,在文本框中输入一个ID,然后单击提交"按钮,它将生成一个仅包含与该ID匹配的行的文件.
我想,当我单击提交"按钮时,它将为我的表中的每个clientID检索一个文件,因为如果我有10.000个以上的clientID,则不会输入ID并单击提交" 10,000次.
我希望我已经足够清楚了,对不起我的英语,并在此先感谢您的回答,提示,链接,任何东西……我真的很受困扰.
In this case, in my Index.cshtml view, I enter an ID in a textbox, and when I click on a submit button, it generate a file with only the lines that match this ID.
I would like, when I click the submit button, it retrieves me a file for each clientID in my table, because if I have more than 10.000 clientID, I won''t enter an ID and click on submit 10.000 times.
I hope I was clear enough, sorry for my english and thanks in advance for your answers, tips, link, anything... I''m really stuck.
推荐答案
for循环怎么样?
示例:
What about a for-loop?
Example:
for(i = 0; i <= clientID; i++)
{
//Code to generate your file here
}
这篇关于如何在一次点击中生成多个文件/账单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!