int columns = 4 + m_ReportData._reportDetail._listColumns._listCols.Count * 3 + 7;
int pageRows = m_PrintRowNumEeveryPage;//每页的行数
int pages = m_ReportData._reportDetail._detailData.Count * 2 / 8;//每页固定显示4个孔道数据
int rows = 15 * pages + m_ReportData._reportDetail._detailData.Count * 2 + 4 * pages;
m_fpSpread.ActiveSheet.Rows.Count = rows;
//设置具有特殊要求的行高和列宽,默认行高为20,列宽为60
for(int pageNo = 0; pageNo<pages; pageNo++)
{
for (int row = pageNo*pageRows; row < pageNo*pageRows+pageRows; row++)
{
if (row == 0 + pageNo * pageRows)//第1行
m_fpSpread.ActiveSheet.Rows[row].Height = 40;
else if (row == pageNo * pageRows + pageRows - 4 || row == pageNo * pageRows + pageRows - 3 || row == pageNo * pageRows + pageRows - 2)//倒数第2、3、4行
m_fpSpread.ActiveSheet.Rows[row].Height = 25;
else if (row == 12 + pageNo * pageRows)//详细数据表头行
m_fpSpread.ActiveSheet.Rows[row].Height = 35;
else if (row == pageNo * pageRows + pageRows - 1)//倒数第1行
m_fpSpread.ActiveSheet.Rows[row].Height = 25;
else if (row > pageNo * pageRows + 13 && row < (pageNo * pageRows + pageRows - 4))//中间的数据区
m_fpSpread.ActiveSheet.Rows[row].Height = 35;
else
m_fpSpread.ActiveSheet.Rows[row].Height = 22;
}
}
for (int col = 0; col < columns; col++)
{
if (col == 2 || col == 3)
m_fpSpread.ActiveSheet.Columns[col].Width = 45;
else if(col == columns-1 ||col == columns-2||col == columns-3||col == columns-4||col == columns-5||col == columns-6||col == columns-7)
m_fpSpread.ActiveSheet.Columns[col].Width = 43;
else
m_fpSpread.ActiveSheet.Columns[col].Width = 35;
}
//开始分页设置打印数据
for(int pageNo = 0; pageNo<pages; pageNo++)
{
LoadPrintDataDetail(pageNo, pages);
MakeTwoDimensionCode();
LoadPrintDataHeader(pageNo, pages);
LoadPrintDataRetail(pageNo, pages);
}
private void LoadPrintDataDetail(int pageNo, int pageNum)
{
_qrCodeString = string.Empty;
_qrCodeString = m_ReportData._reportHead._dragDate + ";";//二维码字符串:张拉日期
int columns = 4 + m_ReportData._reportDetail._listColumns._listCols.Count * 3 + 7;
//=================================详细数据开始==============================
int rowNo = pageNo * m_PrintRowNumEeveryPage+15;
for (int i = 0 + pageNo * 4; i < m_ReportData._reportDetail._detailData.Count && rowNo < (pageNo + 1) * m_PrintRowNumEeveryPage-4; i++, rowNo += 2)
{
DetailDataSource dds = m_ReportData._reportDetail._detailData;
_qrCodeString += dds._no+"@"+dds._zongshenchangliang + ";";//二维码字符串:孔道编号@总伸长量
//0列
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, 0, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, 0].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 0].Value = dds._no;
m_fpSpread.ActiveSheet.Cells[rowNo, 0].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, 0].CellType = m_tctTextNormal;
//1列
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, 1, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, 1].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 1].Value = dds._name;
m_fpSpread.ActiveSheet.Cells[rowNo, 1].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, 1].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, 1, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 1].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 1].Value = dds._name1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 1].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 1].CellType = m_tctTextNormal;
//2,3列
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, 2, 1, 2);
m_fpSpread.ActiveSheet.Cells[rowNo, 2].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, 2].Value = dds._jackNo;
m_fpSpread.ActiveSheet.Cells[rowNo, 2].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, 2].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, 2, 1, 2);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 2].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 2].Value = dds._jackNo1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 2].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, 2].CellType = m_tctTextNormal;
//循环详细数据
int colNo = 3;
for (int j = 0; j < dds._listColsVal.Count; j++)
{
ColumnData cd = dds._listColsVal[j];
//详细数据中的第1列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = cd._col1Val;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Value = cd._col1Val1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].CellType = m_tctTextNormal;
//详细数据中的第2列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = cd._col2Val;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Value = cd._col2Val1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].CellType = m_tctTextNormal;
//详细数据中的第3列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = cd._col3Val;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Value = cd._col3Val1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].CellType = m_tctTextNormal;
}
//倒数第7列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._lijinhuisuoliang;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Value = dds._lijinhuisuoliang1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].CellType = m_tctTextNormal;
//倒数第6列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._gongzuoduanshenchangliang;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo + 1, colNo, 1, 1);
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Value = dds._gongzuoduanshenchangliang1;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo + 1, colNo].CellType = m_tctTextNormal;
//倒数第5列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._shejizhanglali;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
//倒数第4列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._zhanglachangdu;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
//倒数第3列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._lilunshenchangliang;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
//倒数第2列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._zongshenchangliang;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
//倒数第1列
colNo++;
m_fpSpread.ActiveSheet.AddSpanCell(rowNo, colNo, 2, 1);
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Value = dds._shenchanglvwucha;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].Border = m_siThinBorder.Border;
m_fpSpread.ActiveSheet.Cells[rowNo, colNo].CellType = m_tctTextNormal;
}
//=================================详细数据结束==============================
} |