8 个解决方案
#1
用折线图分析商品价格走势的自定义报表示例
private void CreateImage(int ID)
{
int height = 440, width = 600;
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width,height);
Graphics g = Graphics.FromImage(image);
try
{
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 9,FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue,Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown);
string str = "SELECT * FROM tb_Ware WHERE ID=" + Request["ID"] + "";
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
Con.Open();
SqlCommand Com = new SqlCommand(str, Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
g.DrawString(""+dr["Name"].ToString()+"各月份价格走势", font1, brush1, new PointF(130, 30));
}
dr.Close();
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0,0, image.Width - 1, image.Height - 1);
Pen mypen = new Pen(brush,1);
Pen mypen2 = new Pen(Color.Red,2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 12; i++)
{
g.DrawLine(mypen,x, 80, x, 340);
x = x+40;
}
Pen mypen1 = new Pen(Color.Blue,2);
g.DrawLine(mypen1, x-480, 80, x-480, 340);
//绘制横向线条
int y = 106;
for (int i = 0; i <9; i++)
{
g.DrawLine(mypen,60, y, 540, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 540, y);
//x轴
String[] n = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月",
" 八月", " 九月", " 十月", "十一月", "十二月"};
x = 35;
for (int i = 0; i < 12; i++)
{
g.DrawString(n[i].ToString(),font,Brushes.Red, x, 348); //设置文字内容及输出位置
x = x + 40;
}
//y轴
String[] m = {"4500元", " 4000元", " 3500元", " 3000元", " 2500元", " 2000元", " 1500元", " 1000元",
" 500元"};
y = 100;
for (int i = 0; i < 9; i++)
{
g.DrawString(m[i].ToString(),font, Brushes.Red, 10, y); //设置文字内容及输出位置
y = y + 26;
}
int[] Count = new int[12];
string cmdtxt2 = "SELECT * FROM tb_Ware WHERE ID=" + ID + "";
SqlCommand Com1 = new SqlCommand(cmdtxt2, Con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = Com1;
DataSet ds = new DataSet();
da.Fill(ds);
int j = 0;
for(j=0;j<12;j++)
{
Count[j] = Convert.ToInt32(ds.Tables[0].Rows[0][j+2].ToString()) *26/ 500 ;
}
//显示折线效果
SolidBrush mybrush = new SolidBrush(Color.Red);
Point[] points = new Point[12];
points[0].X = 60; points[0].Y = 340 - Count[0];
points[1].X = 100; points[1].Y = 340 - Count[1];
points[2].X = 140; points[2].Y = 340 - Count[2];
points[3].X = 180; points[3].Y = 340 - Count[3];
points[4].X = 220; points[4].Y = 340 - Count[4];
points[5].X = 260; points[5].Y = 340 - Count[5];
points[6].X = 300; points[6].Y = 340 - Count[6];
points[7].X = 340; points[7].Y = 340 - Count[7];
points[8].X = 380; points[8].Y = 340 - Count[8];
points[9].X = 420; points[9].Y = 340 - Count[9];
points[10].X = 460; points[10].Y = 340 - Count[10];
points[11].X = 500; points[11].Y = 340 - Count[11];
g.DrawLines(mypen2, points); //绘制折线
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
}
private void CreateImage(int ID)
{
int height = 440, width = 600;
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width,height);
Graphics g = Graphics.FromImage(image);
try
{
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 9,FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue,Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown);
string str = "SELECT * FROM tb_Ware WHERE ID=" + Request["ID"] + "";
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
Con.Open();
SqlCommand Com = new SqlCommand(str, Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
g.DrawString(""+dr["Name"].ToString()+"各月份价格走势", font1, brush1, new PointF(130, 30));
}
dr.Close();
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0,0, image.Width - 1, image.Height - 1);
Pen mypen = new Pen(brush,1);
Pen mypen2 = new Pen(Color.Red,2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 12; i++)
{
g.DrawLine(mypen,x, 80, x, 340);
x = x+40;
}
Pen mypen1 = new Pen(Color.Blue,2);
g.DrawLine(mypen1, x-480, 80, x-480, 340);
//绘制横向线条
int y = 106;
for (int i = 0; i <9; i++)
{
g.DrawLine(mypen,60, y, 540, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 540, y);
//x轴
String[] n = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月",
" 八月", " 九月", " 十月", "十一月", "十二月"};
x = 35;
for (int i = 0; i < 12; i++)
{
g.DrawString(n[i].ToString(),font,Brushes.Red, x, 348); //设置文字内容及输出位置
x = x + 40;
}
//y轴
String[] m = {"4500元", " 4000元", " 3500元", " 3000元", " 2500元", " 2000元", " 1500元", " 1000元",
" 500元"};
y = 100;
for (int i = 0; i < 9; i++)
{
g.DrawString(m[i].ToString(),font, Brushes.Red, 10, y); //设置文字内容及输出位置
y = y + 26;
}
int[] Count = new int[12];
string cmdtxt2 = "SELECT * FROM tb_Ware WHERE ID=" + ID + "";
SqlCommand Com1 = new SqlCommand(cmdtxt2, Con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = Com1;
DataSet ds = new DataSet();
da.Fill(ds);
int j = 0;
for(j=0;j<12;j++)
{
Count[j] = Convert.ToInt32(ds.Tables[0].Rows[0][j+2].ToString()) *26/ 500 ;
}
//显示折线效果
SolidBrush mybrush = new SolidBrush(Color.Red);
Point[] points = new Point[12];
points[0].X = 60; points[0].Y = 340 - Count[0];
points[1].X = 100; points[1].Y = 340 - Count[1];
points[2].X = 140; points[2].Y = 340 - Count[2];
points[3].X = 180; points[3].Y = 340 - Count[3];
points[4].X = 220; points[4].Y = 340 - Count[4];
points[5].X = 260; points[5].Y = 340 - Count[5];
points[6].X = 300; points[6].Y = 340 - Count[6];
points[7].X = 340; points[7].Y = 340 - Count[7];
points[8].X = 380; points[8].Y = 340 - Count[8];
points[9].X = 420; points[9].Y = 340 - Count[9];
points[10].X = 460; points[10].Y = 340 - Count[10];
points[11].X = 500; points[11].Y = 340 - Count[11];
g.DrawLines(mypen2, points); //绘制折线
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
}
#2
推荐fastreport,简单易用,该有的功能基本都有
#3
这个收费么 没有接触过啊 和activereport 比较呢
#4
看着好多啊 哈哈 谢谢啊 我想知道用哪个控件 或者用过的经验
#5
想出质检类的那种报告
#6
#7
我做自定义报表用的是finereport,你也可以试试,功能挺强大的,而且官网有免费版,比excel做报表高效,而且与excel可以无缝导入导出,打印设置也很灵活方便。
#8
如何快速创建水晶报表
(过程省略)主程序如此)
private void Frm_Main_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = new MyCrystalReport();//将报表绑定到CrystalReportViewer控件//codego.net/1/1/1/
}
(过程省略)主程序如此)
private void Frm_Main_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = new MyCrystalReport();//将报表绑定到CrystalReportViewer控件//codego.net/1/1/1/
}
#1
用折线图分析商品价格走势的自定义报表示例
private void CreateImage(int ID)
{
int height = 440, width = 600;
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width,height);
Graphics g = Graphics.FromImage(image);
try
{
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 9,FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue,Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown);
string str = "SELECT * FROM tb_Ware WHERE ID=" + Request["ID"] + "";
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
Con.Open();
SqlCommand Com = new SqlCommand(str, Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
g.DrawString(""+dr["Name"].ToString()+"各月份价格走势", font1, brush1, new PointF(130, 30));
}
dr.Close();
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0,0, image.Width - 1, image.Height - 1);
Pen mypen = new Pen(brush,1);
Pen mypen2 = new Pen(Color.Red,2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 12; i++)
{
g.DrawLine(mypen,x, 80, x, 340);
x = x+40;
}
Pen mypen1 = new Pen(Color.Blue,2);
g.DrawLine(mypen1, x-480, 80, x-480, 340);
//绘制横向线条
int y = 106;
for (int i = 0; i <9; i++)
{
g.DrawLine(mypen,60, y, 540, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 540, y);
//x轴
String[] n = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月",
" 八月", " 九月", " 十月", "十一月", "十二月"};
x = 35;
for (int i = 0; i < 12; i++)
{
g.DrawString(n[i].ToString(),font,Brushes.Red, x, 348); //设置文字内容及输出位置
x = x + 40;
}
//y轴
String[] m = {"4500元", " 4000元", " 3500元", " 3000元", " 2500元", " 2000元", " 1500元", " 1000元",
" 500元"};
y = 100;
for (int i = 0; i < 9; i++)
{
g.DrawString(m[i].ToString(),font, Brushes.Red, 10, y); //设置文字内容及输出位置
y = y + 26;
}
int[] Count = new int[12];
string cmdtxt2 = "SELECT * FROM tb_Ware WHERE ID=" + ID + "";
SqlCommand Com1 = new SqlCommand(cmdtxt2, Con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = Com1;
DataSet ds = new DataSet();
da.Fill(ds);
int j = 0;
for(j=0;j<12;j++)
{
Count[j] = Convert.ToInt32(ds.Tables[0].Rows[0][j+2].ToString()) *26/ 500 ;
}
//显示折线效果
SolidBrush mybrush = new SolidBrush(Color.Red);
Point[] points = new Point[12];
points[0].X = 60; points[0].Y = 340 - Count[0];
points[1].X = 100; points[1].Y = 340 - Count[1];
points[2].X = 140; points[2].Y = 340 - Count[2];
points[3].X = 180; points[3].Y = 340 - Count[3];
points[4].X = 220; points[4].Y = 340 - Count[4];
points[5].X = 260; points[5].Y = 340 - Count[5];
points[6].X = 300; points[6].Y = 340 - Count[6];
points[7].X = 340; points[7].Y = 340 - Count[7];
points[8].X = 380; points[8].Y = 340 - Count[8];
points[9].X = 420; points[9].Y = 340 - Count[9];
points[10].X = 460; points[10].Y = 340 - Count[10];
points[11].X = 500; points[11].Y = 340 - Count[11];
g.DrawLines(mypen2, points); //绘制折线
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
}
private void CreateImage(int ID)
{
int height = 440, width = 600;
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width,height);
Graphics g = Graphics.FromImage(image);
try
{
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 9,FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue,Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown);
string str = "SELECT * FROM tb_Ware WHERE ID=" + Request["ID"] + "";
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
Con.Open();
SqlCommand Com = new SqlCommand(str, Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
g.DrawString(""+dr["Name"].ToString()+"各月份价格走势", font1, brush1, new PointF(130, 30));
}
dr.Close();
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0,0, image.Width - 1, image.Height - 1);
Pen mypen = new Pen(brush,1);
Pen mypen2 = new Pen(Color.Red,2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 12; i++)
{
g.DrawLine(mypen,x, 80, x, 340);
x = x+40;
}
Pen mypen1 = new Pen(Color.Blue,2);
g.DrawLine(mypen1, x-480, 80, x-480, 340);
//绘制横向线条
int y = 106;
for (int i = 0; i <9; i++)
{
g.DrawLine(mypen,60, y, 540, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 540, y);
//x轴
String[] n = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月",
" 八月", " 九月", " 十月", "十一月", "十二月"};
x = 35;
for (int i = 0; i < 12; i++)
{
g.DrawString(n[i].ToString(),font,Brushes.Red, x, 348); //设置文字内容及输出位置
x = x + 40;
}
//y轴
String[] m = {"4500元", " 4000元", " 3500元", " 3000元", " 2500元", " 2000元", " 1500元", " 1000元",
" 500元"};
y = 100;
for (int i = 0; i < 9; i++)
{
g.DrawString(m[i].ToString(),font, Brushes.Red, 10, y); //设置文字内容及输出位置
y = y + 26;
}
int[] Count = new int[12];
string cmdtxt2 = "SELECT * FROM tb_Ware WHERE ID=" + ID + "";
SqlCommand Com1 = new SqlCommand(cmdtxt2, Con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = Com1;
DataSet ds = new DataSet();
da.Fill(ds);
int j = 0;
for(j=0;j<12;j++)
{
Count[j] = Convert.ToInt32(ds.Tables[0].Rows[0][j+2].ToString()) *26/ 500 ;
}
//显示折线效果
SolidBrush mybrush = new SolidBrush(Color.Red);
Point[] points = new Point[12];
points[0].X = 60; points[0].Y = 340 - Count[0];
points[1].X = 100; points[1].Y = 340 - Count[1];
points[2].X = 140; points[2].Y = 340 - Count[2];
points[3].X = 180; points[3].Y = 340 - Count[3];
points[4].X = 220; points[4].Y = 340 - Count[4];
points[5].X = 260; points[5].Y = 340 - Count[5];
points[6].X = 300; points[6].Y = 340 - Count[6];
points[7].X = 340; points[7].Y = 340 - Count[7];
points[8].X = 380; points[8].Y = 340 - Count[8];
points[9].X = 420; points[9].Y = 340 - Count[9];
points[10].X = 460; points[10].Y = 340 - Count[10];
points[11].X = 500; points[11].Y = 340 - Count[11];
g.DrawLines(mypen2, points); //绘制折线
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
}
#2
推荐fastreport,简单易用,该有的功能基本都有
#3
这个收费么 没有接触过啊 和activereport 比较呢
#4
看着好多啊 哈哈 谢谢啊 我想知道用哪个控件 或者用过的经验
#5
想出质检类的那种报告
#6
#7
我做自定义报表用的是finereport,你也可以试试,功能挺强大的,而且官网有免费版,比excel做报表高效,而且与excel可以无缝导入导出,打印设置也很灵活方便。
#8
如何快速创建水晶报表
(过程省略)主程序如此)
private void Frm_Main_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = new MyCrystalReport();//将报表绑定到CrystalReportViewer控件//codego.net/1/1/1/
}
(过程省略)主程序如此)
private void Frm_Main_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = new MyCrystalReport();//将报表绑定到CrystalReportViewer控件//codego.net/1/1/1/
}