Search in sources :

Example 1 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class FormTemplate method output.

@Override
public void output(WritableSheet sheet) throws RowsExceededException, WriteException {
    // 输出列头
    Record head = this.getDataSet().getHead();
    if (heads != null) {
        for (int lineNo = 0; lineNo < heads.size(); lineNo++) {
            Column column = heads.get(lineNo);
            int row = this.getRow() + lineNo;
            Label item1 = new Label(0, row, column.getName());
            sheet.addCell(item1);
            // Label item2 = new Label(1, lineNo,
            // head.getString(column.getCode()));
            // sheet.addCell(item2);
            column.setRecord(head);
            writeColumn(sheet, 1, row, column);
        }
        // 设置新的起点行号
        this.setRow(this.getRow() + heads.size());
    }
    // 输出原来的表格
    super.output(sheet);
    // 输出合计
    if (footer != null)
        footer.output(this, sheet);
}
Also used : Label(jxl.write.Label) Record(cn.cerc.jdb.core.Record)

Example 2 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class InvoiceTemplate method output.

@Override
public void output(Document document, PdfWriter writer) throws DocumentException, IOException {
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 设置中文字体和字体样式
    Font f8 = new Font(bfChinese, 8, Font.NORMAL);
    Font f18 = new Font(bfChinese, 18, Font.NORMAL);
    document.addTitle(this.getFileName());
    // 页标题
    Paragraph title = new Paragraph(this.getFileName(), f18);
    title.setAlignment(Element.ALIGN_CENTER);
    document.add(title);
    // 空一行
    document.add(new Paragraph(" ", f18));
    // 创建一个N列的表格控件
    PdfPTable pdfTable = new PdfPTable(2);
    // 设置报表为无边框
    pdfTable.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    // 设置表格占PDF文档100%宽度
    pdfTable.setWidthPercentage(100);
    // 水平方向表格控件左对齐
    pdfTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    // 创建一个表格的表头单元格
    PdfPCell pdfTableHeaderCell = new PdfPCell();
    // 设置表格的表头单元格颜色
    pdfTableHeaderCell.setBackgroundColor(new BaseColor(240, 240, 240));
    pdfTableHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    // 设置表头栏位
    pdfTableHeaderCell.setPhrase(new Paragraph("名称", f8));
    pdfTable.addCell(pdfTableHeaderCell);
    pdfTableHeaderCell.setPhrase(new Paragraph("信息", f8));
    pdfTable.addCell(pdfTableHeaderCell);
    // 创建一个表格的正文内容单元格
    PdfPCell pdfTableContentCell_1 = new PdfPCell();
    pdfTableContentCell_1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    pdfTableContentCell_1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    PdfPCell pdfTableContentCell_2 = new PdfPCell();
    pdfTableContentCell_2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    pdfTableContentCell_2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    // 表格内容行数的填充
    dataSet.first();
    while (dataSet.fetch()) {
        Record record = dataSet.getCurrent();
        for (Column column : this.getColumns()) {
            pdfTableContentCell_1.setPhrase(new Phrase(column.getName(), f8));
            pdfTable.addCell(pdfTableContentCell_1);
            String field = column.getCode();
            pdfTableContentCell_2.setPhrase(new Paragraph(record.getString(field), f8));
            pdfTable.addCell(pdfTableContentCell_2);
        }
    }
    document.add(pdfTable);
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) BaseColor(com.itextpdf.text.BaseColor) PdfPTable(com.itextpdf.text.pdf.PdfPTable) Column(cn.cerc.jexport.excel.Column) BaseFont(com.itextpdf.text.pdf.BaseFont) Record(cn.cerc.jdb.core.Record) Phrase(com.itextpdf.text.Phrase) Font(com.itextpdf.text.Font) BaseFont(com.itextpdf.text.pdf.BaseFont) Paragraph(com.itextpdf.text.Paragraph)

Example 3 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class Template method output.

public void output(Document document, PdfWriter writer) throws DocumentException, IOException {
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 设置中文字体和字体样式
    Font f8 = new Font(bfChinese, 8, Font.NORMAL);
    Font f18 = new Font(bfChinese, 18, Font.NORMAL);
    document.addTitle(this.getFileName());
    // 页标题
    Paragraph title = new Paragraph(this.getFileName(), f18);
    title.setAlignment(Element.ALIGN_CENTER);
    document.add(title);
    // 空一行
    document.add(new Paragraph(" ", f18));
    // 创建一个N列的表格控件
    PdfPTable pdfTable = new PdfPTable(this.getColumns().size());
    // 设置表格占PDF文档100%宽度
    pdfTable.setWidthPercentage(100);
    // 水平方向表格控件左对齐
    pdfTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    // 创建一个表格的表头单元格
    PdfPCell pdfTableHeaderCell = new PdfPCell();
    // 设置表格的表头单元格颜色
    pdfTableHeaderCell.setBackgroundColor(new BaseColor(240, 240, 240));
    pdfTableHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    for (Column column : this.getColumns()) {
        Paragraph item = new Paragraph(column.getName(), f8);
        pdfTableHeaderCell.setPhrase(item);
        pdfTable.addCell(pdfTableHeaderCell);
    }
    // 创建一个表格的正文内容单元格
    PdfPCell pdfTableContentCell = new PdfPCell();
    pdfTableContentCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    pdfTableContentCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    // 表格内容行数的填充
    dataSet.first();
    while (dataSet.fetch()) {
        Record record = dataSet.getCurrent();
        for (Column column : this.getColumns()) {
            String field = column.getCode();
            pdfTableContentCell.setPhrase(new Paragraph(record.getString(field), f8));
            pdfTable.addCell(pdfTableContentCell);
        }
    }
    document.add(pdfTable);
// //将表格添加到新的文档
// doc.add(table);
// //创建新的一页
// doc.newPage();
// //添加图片
// Image image = Image.getInstance(
// "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");
// //添加到文档
// doc.add(image);
// //设置对象方式
// image.setAlignment(Element.ALIGN_CENTER);
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) BaseColor(com.itextpdf.text.BaseColor) PdfPTable(com.itextpdf.text.pdf.PdfPTable) Column(cn.cerc.jexport.excel.Column) BaseFont(com.itextpdf.text.pdf.BaseFont) Record(cn.cerc.jdb.core.Record) Font(com.itextpdf.text.Font) BaseFont(com.itextpdf.text.pdf.BaseFont) Paragraph(com.itextpdf.text.Paragraph)

Example 4 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class IServiceProxy method delete.

// delete
public default boolean delete(Object... args) {
    Record headIn = this.getDataIn().getHead();
    headIn.setField("_method_", "delete");
    return exec(args);
}
Also used : Record(cn.cerc.jdb.core.Record)

Example 5 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class IServiceProxy method post.

// append
public default boolean post(Object... args) {
    Record headIn = this.getDataIn().getHead();
    headIn.setField("_method_", "post");
    return exec(args);
}
Also used : Record(cn.cerc.jdb.core.Record)

Aggregations

Record (cn.cerc.jdb.core.Record)53 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)15 LocalService (cn.cerc.jbean.client.LocalService)9 Webfunc (cn.cerc.jbean.core.Webfunc)4 DataSet (cn.cerc.jdb.core.DataSet)4 Ignore (org.junit.Ignore)4 Test (org.junit.Test)4 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)3 StubHandle (cn.cerc.jbean.rds.StubHandle)3 IMemcache (cn.cerc.jdb.cache.IMemcache)3 MessageRecord (cn.cerc.jmis.message.MessageRecord)3 UrlRecord (cn.cerc.jpage.core.UrlRecord)3 Label (jxl.write.Label)3 CustomHandle (cn.cerc.jbean.core.CustomHandle)2 IService (cn.cerc.jbean.core.IService)2 IStatus (cn.cerc.jbean.core.IStatus)2 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)2 QueueQuery (cn.cerc.jdb.queue.QueueQuery)2 Column (cn.cerc.jexport.excel.Column)2 JPushRecord (cn.cerc.jmis.message.JPushRecord)2