The report system is an important part of the information system. When preparing a report system, we want the report builder to be separated from the logical part of the report,
In this way, no matter what report output technology is used, the business logic is not affected. For example, when outputting reports, users often want to be compatible with MS Office,
The report is output to MS Excel or MS Word, and the upgrade of the office system will lead to the upgrade of the report system,
To improve the adaptability of the application system, the bridge mode can be used to reduce the impact of MS Office software upgrade on the system.
Using system;
Using system. collections;
Using system. Data;
Using system. Drawing. drawing2d;
Using system. drawing;
Namespace reportbridge
...{
Public interface hreport
...{
Void writetitle (String title );
Void writeauthor (string author );
Void writehead (arraylist H );
Void writecontent (Dataset DS );
}
Public interface reportwriter
...{
Void newreport (string filename );
Void write (INT Col, int row, string cotent, font F, color C );
Void savereport ();
}
Public class report: hreport
...{
Private reportwriter m_writer;
Public Report (reportwriter t_rw)
...{
M_writer = t_rw;
}
Hreport member # region hreport Member
Public void writetitle (String title)
...{
// Todo: Add Report. writetitle implementation
}
Public void writeauthor (string author)
...{
// Todo: Add Report. writeauthor implementation
}
Public void writehead (arraylist H)
...{
// Todo: Add Report. writehead implementation
}
Public void writecontent (Dataset DS)
...{
// Todo: Add Report. writecontent implementation
}
# Endregion
}
Public class BMP reportwriter: reportwriter
...{
Reportwriter member # region reportwriter Member
Public void newreport (string filename)
...{
// Todo: Add BMP reportwriter. newreport implementation
}
Public void write (INT Col, int row, string cotent, font F, color C)
...{
// Todo: add the BMP reportwriter. Write implementation
}
Public void savereport ()
...{
// Todo: add the BMP reportwriter. savereport implementation
}
# Endregion
}
Public class excelreportwriter: reportwriter
...{
Reportwriter member # region reportwriter Member
Public void newreport (string filename)
...{
// Todo: Add excelreportwriter. newreport implementation
}
Public void write (INT Col, int row, string cotent, font F, color C)
...{
// Todo: Add excelreportwriter. Write implementation
}
Public void savereport ()
...{
// Todo: Add excelreportwriter. savereport implementation
}
# Endregion
}
Public class invoker
...{
Public void run ()
...{
BMP reportwriter m_brw = new BMP reportwriter ();
Hreport M_r = new report (m_brw );
M_r.writeauthor ("myauthor ");
}
}
}