Foros del Web » Programación para mayores de 30 ;) » .NET »

Root.Reports!!!

Estas en el tema de Root.Reports!!! en el foro de .NET en Foros del Web. Hola a todos, bueno he estado utilizando el namespace Root.Reports, es buenisima, (a los que no conocen : http://report.sourceforge.net/ ) y bueno la generacion de ...
  #1 (permalink)  
Antiguo 16/03/2005, 15:30
Avatar de rodri  
Fecha de Ingreso: febrero-2005
Mensajes: 406
Antigüedad: 19 años, 3 meses
Puntos: 2
Sonrisa Root.Reports!!!

Hola a todos, bueno he estado utilizando el namespace Root.Reports, es buenisima, (a los que no conocen : http://report.sourceforge.net/) y bueno la generacion de PDF es fantastica, pero tengo un problema, he copiado el codigo de un Sample para generar Reportes con Datagrids, esto lo saque del mismo sitio, y tengo ahora un problema al compilar, me sale que la clave no puede ser nula (un problema con Key) y no genera el reporte a PDF, este el codigo en C#

public class MiClaseReporte:Report
{
//definimos los campos de la definición de fuentes y bordes
private FontDef fd;
private double rPosLeft = 20;
private double rPosRight= 195;
private double rPosTop= 24;
private double rPosBottom= 278;
private string sConnectionString =@"Provider=SQLOLEDB;initial catalog=northwind;user id=sa;password='password'";


protected override void Create()
{
new Root.Reports.Page(this);
fd = new FontDef(this, FontDef.StandardFont.Helvetica);
FontProp fp = new FontPropMM(fd, 1.9); // standard font
FontProp fp_Header = new FontPropMM(fd, 1.9); // font of the table header
fp_Header.bBold = true;

Stream stream_Phone = GetType().Assembly.GetManifestResourceStream("Repo rtSamples.Phone.jpg");
Random random = new Random(6);

// create table
using (TableLayoutManager tlm = new TableLayoutManager(fp_Header))
{//3

tlm.rContainerHeightMM = rPosBottom - rPosTop; // set height of table
tlm.headerCellDef.rAlignV = RepObj.rAlignCenter; // set vertical alignment of all header cells
tlm.cellDef.pp_LineBottom = new PenProp(this, 0.05, Color.LightGray); // set bottom line for all cells
tlm.eNewContainer += new TableLayoutManager.NewContainerEventHandler(this.T lm_NewContainer);

// define columns
TableLayoutManager.Column col;
col = new TableLayoutManager.ColumnMM(tlm, "ID", 13);

col = new TableLayoutManager.ColumnMM(tlm, "Company Name", 40);
col.cellDef.textMode = TableLayoutManager.TextMode.MultiLine;

col = new TableLayoutManager.ColumnMM(tlm, "Address", 36);

col = new TableLayoutManager.ColumnMM(tlm, "City", 22);

col = new TableLayoutManager.ColumnMM(tlm, "Postal Code", 16);

col = new TableLayoutManager.ColumnMM(tlm, "Country", 18);

TableLayoutManager.Column col_Phone = new TableLayoutManager.ColumnMM(tlm, "Phone", rPosRight - rPosLeft - tlm.rWidthMM);
col_Phone.fp_Header = new FontPropMM(fd, 1.9, Color.Brown);
col_Phone.headerCellDef.rAlignH = RepObj.rAlignRight;
col_Phone.cellDef.rAlignH = RepObj.rAlignRight;
BrushProp bp_Phone = new BrushProp(this, Color.FromArgb(255, 255, 200));
col_Phone.cellDef.bp_Back = bp_Phone;

// open database
using (OleDbConnection oleDbConnection = new OleDbConnection(sConnectionString))
{//2
oleDbConnection.Open();
OleDbCommand oleDbCommand = new OleDbCommand("SELECT CustomerID, CompanyName, Address, City, PostalCode, Country, Phone FROM Customers where Country='USA' ORDER BY CompanyName", oleDbConnection);
// read rows
using (OleDbDataReader oddr = oleDbCommand.ExecuteReader())
{//1
BrushProp bp_USA = new BrushProp(this, Color.FromArgb(255, 180, 180));
while (oddr.Read())
{
tlm.cellDef.bp_Back = (oddr.GetString(5) == "USA" ? bp_USA : null);
col_Phone.cellDef.bp_Back = (oddr.GetString(5) == "USA" ? new BrushProp(this, Color.FromArgb(255, 227, 50)) : bp_Phone);
tlm.NewRow();
tlm.Add(0, new RepString(fp, oddr.GetString(0)));
tlm.Add(1, new RepString(fp, oddr.GetString(1)));
tlm.Add(2, new RepString(fp, oddr.GetString(2)));
tlm.Add(3, new RepString(fp, oddr.GetString(3)));
if (!oddr.IsDBNull(4)) {
tlm.Add(4, new RepString(fp, oddr.GetString(4)));
}
tlm.Add(5, new RepString(fp, oddr.GetString(5)));
tlm.Add(6, new RepString(fp, oddr.GetString(6)));
if (random.NextDouble() < 0.2)
{ // mark randomly selected row with a phone icon
tlm.tlmRow_Cur.aTlmCell[col_Phone].AddMM(1, 0.25, new RepImageMM(stream_Phone, 2.1, 2.3));
}
}//while
}//using1
}//using2
}//using3

// print page number and current date/time
foreach (Root.Reports.Page page in enum_Page)
{
Double rY = rPosBottom + 1.5;
page.AddLT_MM(rPosLeft, rY, new RepString(fp, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()));
page.AddRT_MM(rPosRight, rY, new RepString(fp, page.iPageNo + " / " + iPageCount));
}

}


private void Tlm_NewContainer(Object oSender, TableLayoutManager.NewContainerEventArgs ea)
{ // only "public" for NDoc, should be "private"
new Root.Reports.Page(this);

// first page with caption
if (page_Cur.iPageNo == 1) {
FontProp fp_Title = new FontPropMM(fd, 7);
fp_Title.bBold = true;
page_Cur.AddCT_MM(rPosLeft + (rPosRight - rPosLeft) / 2, rPosTop, new RepString(fp_Title, "Customer List"));
ea.container.rHeightMM -= fp_Title.rLineFeedMM; // reduce height of table container for the first page
}

// the new container must be added to the current page
page_Cur.AddMM(rPosLeft, rPosBottom - ea.container.rHeightMM, ea.container);
}
}



y luego en el evento que llama al reporte
{
RT.ResponsePDF(new MiClaseReporte(),this);
}
eso deberia generar un reporte que muestre DataGrids

Por favor ayuda , como es eso de q "la clave no puede ser nula" ??? (esto en ejecucion de la pagina aspx).
Gracias por su tiempo
__________________
0.o Rodri
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:48.