PrintDataSource.cs
资源名称:GOLDPRINT.rar [点击查看]
上传用户:jx_fiona
上传日期:2014-03-08
资源大小:1387k
文件大小:1k
源码类别:
打印编程
开发平台:
Others
- using System;
- using System.Data;
- namespace MisGoldPrinterTest
- {
- /// <summary>
- /// 为打印提供测试数据
- /// </summary>
- public class PrintDataSource
- {
- public static DataTable GetDataSource(int p_DataRows)
- {
- DataTable dt = new DataTable();
- int rows = p_DataRows;
- int cols = 6;
- //增加行
- for (int intRowIndex=0;intRowIndex<rows;intRowIndex++)
- {
- dt.Rows.Add(dt.NewRow());
- }
- //增加新列
- for (int intColIndex=0;intColIndex<cols;intColIndex++)
- {
- //dt.Columns.Add(intColIndex.ToString());
- dt.Columns.Add();
- //填写默认值为空串
- dt.Columns[intColIndex].DefaultValue = "";
- }
- int i,j;
- for(i=0 ;i< rows ; i++)
- {
- dt.Rows[i][0] = (i + 1).ToString(); //序列
- for(j=1 ;j< cols-3 ; j++)
- {
- dt.Rows[i][j] = (i + 1).ToString() + "行" + (j + 1).ToString() + "列";
- dt.Rows[i][cols-3] = (j + 1).ToString() + "." + (i + 1).ToString();
- dt.Rows[i][cols-2] = (i + 1).ToString();
- }
- dt.Rows[i][cols-1] = (double.Parse(dt.Rows[i][cols-2].ToString()) * double.Parse(dt.Rows[i][cols-3].ToString())).ToString();
- }
- return dt;
- }
- }//End Class
- }//End Namespace