我有一个包含类的结果数据的表。我创建了一个选择所有表数据的存储过程。 现在的问题是我需要为每个学生单独报告,并希望一次以pdf格式保存所有报告。我想使用一次选择所有数据的存储过程。
答案 0 :(得分:1)
要达到您想要的目标,请按照以下说明进行操作
在C#表单中添加以下代码
private void button1_Click(object sender, EventArgs e)
{
CrystalReport1 report1 = new CrystalReport1();
report1.SetDatabaseLogon("Username","Password");
report1.SetParameterValue("Parametername", textBox1.Text);
report1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "Student" + textBox1.Text + ".pdf");
crystalReportViewer1.ReportSource = report1; //Remove this if you don't want a viewer.
}
这将根据提供的ID为学生创建PDF文件,并在查看器中预览报告。如果要为所有学生创建PDF文件,则必须循环遍历所有ID并根据相同的原则导出文件。
要使用上述代码,只需将“用户名”和“密码”替换为数据库的凭据,将“Parametername”替换为您在存储过程中使用的名称。
答案 1 :(得分:0)
我使用部分专家,然后在此处转到详细信息部分,然后分页选项,并在一个可见记录后设置新页面。就像那样..
现在这很好用。
答案 2 :(得分:0)
有两种方法可以实现您的目标:
一个。创建一个报告,其中包含有关所有学生的信息,按学生对信息进行分组并将报告破解为pdf。 Bursting将为每个组(学生)生成单独的PDF文件
B中。创建一个报告,其中包含单个学生的信息,创建学生列表并为列表中的每个记录运行报告。
市场上有一些工具可用于生成PDF文件。 我正在使用R-Tag(http://www.r-tag.com/Pages/ReportManager.aspx)。它不是免费的,而是提供30天的全功能试用期,这将足以让您完成任务。
答案 3 :(得分:0)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NameSpace
{
class Program
{
struct student
{
public string stid;
public string stname;
public string stage;
};
static void Main(string[] args)
{
student[] st = new student[4];
int choice;
string confirm;
int count = 0;
Console.WriteLine("Enter Student Data");
Console.WriteLine("1. ADD");
Console.WriteLine("2. UPDATE");
Console.WriteLine("3. DELETE");
Console.WriteLine("4. SHOW");
do
{
Console.Write("enter your choice(1-4):");
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Add(st, count);
count++;
break;
case 2:
Update(st);
break;
case 3:
Delete(st);
break;
case 4:
Show(st);
break;
default:
Console.WriteLine("\nEnter b/w 1-4\n");
break;
}
Console.Write("Press Y or y to continue:");
confirm = Console.ReadLine().ToString();
} while (confirm == "Y" || confirm == "y");
}
static void Add(student[] st, int count)
{
Console.Write("\nEnter student ID: ");
st[count].stid = Console.ReadLine();
Console.Write("Enter student name: ");
st[count].stname = Console.ReadLine();
Console.Write("Enter student age: ");
st[count].stage = Console.ReadLine();
}
static void Show(student[] st)
{
for (int count = 0; count < st.Length; count++)
{
if (st[count].stid != null)
{
Console.WriteLine("\nStudent ID : " + st[count].stid);
Console.WriteLine("Student Name : " + st[count].stname);
Console.WriteLine("Student Age : " + st[count].stage);
}
}
}
static void Delete(student[] st)
{
Console.Write("\nEnter student ID: ");
string studid = Console.ReadLine();
for (int count = 0; count < st.Length; count++)
{
if (studid == st[count].stid)
{
st[count].stid = null;
st[count].stname = null;
st[count].stage = null;
}
}
}
static void Update(student[] st)
{
Console.Write("\nEnter student ID: ");
string studid = Console.ReadLine();
for (int count = 0; count < st.Length; count++)
{
if (studid == st[count].stid)
{
Console.Write("Enter student name: ");
st[count].stname = Console.ReadLine();
Console.Write("Enter student age: ");
st[count].stage = Console.ReadLine();
}
}
}
}
}