Spread undoubtedly is one of the most powerful grids available in the market and is justified by tons of features packaged together with it. While developing Spread, we put more influence on customizability and ease of use along with its very attractive features. Time and again, it has been proved that Spread's USP is its ease of customization and development. Spread allows you to select from a large range of printing options to provide customized printing. Along with the provided printing options you may use several properties of the grid to leverage your use case. One such instance which we are going to discuss here came to us few days back and the requirement was to print only the selected rows from a sheet. Plus, while printing it was paramount that the rows must not look discontinuous. In other words, rows n, n+k and n+l , where(n>0, k>0, l>0) when selected must become row 1,2 and 3 respectively. Let's take a look how this can be performed using the following approach.
Implementation
1. Create a temporary copy of the source sheet.
SheetView sv = (SheetView)Serializer.LoadObjectXml(typeof(SheetView), Serializer.GetObjectXml(fpSpread1.ActiveSheet, "CopySheet"), "CopySheet");
sv.SheetName = "CopySheet";
2. Change the visibility of all the unselected rows.
for (int \_rowIndex = fpSpread1.ActiveSheet.RowCount - 1; \_rowIndex >= 0; _rowIndex--)
{
if (!fpSpread1.ActiveSheet.IsAnyCellInRowSelected(_rowIndex))
{
sv.Rows[_rowIndex].Visible = false;
}
}
3. Update the row index of each selected row.
for (int count = 1, \_rowIndex = 0; \_rowIndex < sv.RowCount; _rowIndex++)
{
if (sv.Rows[_rowIndex].Visible)
{
sv.Rows[_rowIndex].Label = count.ToString();
count++;
}
}
4. Print the row.
sv.PrintInfo.Centering = Centering.Horizontal;
sv.PrintInfo.Preview = true;
fpSpread1.PrintSheet(sv);
And, that's it :) For more such features, please visit this page. Download C# Sample Download VB Sample