to zxhong(红) ,
有这样的么?

解决方案 »

  1.   

    纯用Javascript打印<object classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0>
    </object> 
    <script language="JavaScript"> 
    function doPrintSetup(){
    //打印设置
    WB.ExecWB(8,1)
    }
    function doPrintPreview(){
    //打印预览
    WB.ExecWB(7,1)
    }
    </script>再用按钮分别调用。
      

  2.   

    生成Word文件打印,有安全提示,需客户端装有word,IE6通过。<html>
    <head>
    <title>Build Document by Script</TITLE>
    </HEAD>
    <Table id="myData" border=1 align=center>
    <Tr align=center>
    <Td>产品名称</Td>
    <Td>产品描述</Td>
    <Td>产品单价</Td>
    <Td>产品等级</Td>
    </Tr>
    <Tr align=center>
    <Td>产品一</Td>
    <Td>This is a test</Td>
    <Td align=right>300.50</Td>
    <Td>一级</Td>
    </Tr>
    <Tr align=center>
    <Td>产品二</Td>
    <Td>This is a test</Td>
    <Td align=right>300.50</Td>
    <Td>一级</Td>
    </Tr>
    <Tr align=center>
    <Td>产品三</Td>
    <Td>This is a test</Td>
    <Td align=right>300.50</Td>
    <Td>一级</Td>
    </Tr>
    </Tabld>
    <input type=button onclick="vbscript:buildDoc '',4" value="build">
    <BODY>
    </BODY>
    </HTML>
    <script language="vbscript">
    Sub buildDoc(theTemplate,intTableRows)
    Dim Table1
    set Table1 = document.all.myData
    row = Table1.rows.length
    Set objWordDoc = CreateObject("Word.Document")
    ObjWordDoc.Application.Visible=True
    Dim theArray(4,4)
    'Redim Preserve theArray(4,row)
    colnum = Table1.rows(1).cells.length
    for i=0 to row-1
    for j=0 to colnum-1
    theArray(j+1,i+1) = Table1.rows(i).cells(j).innerHTML
    next
    nextintNumrows = 4objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("测试的表格")
    objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
    objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")Set rngPara = objWordDoc.Application.ActiveDocument.Paragraphs(1).Range
    With rngPara
    .Bold = True
    .ParagraphFormat.Alignment = 1
    .Font.Name = "Arial"
    .Font.Size = 12
    End WithSet rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range
    Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,intNumrows,4)for i = 1 to colnum
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
    next
    tabRow = 2For j = 2 to intNumrows
    'ObjWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Borders.Enable=False
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).Range.InsertAfter theArray(1,j)
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).Range.ParagraphFormat.alignment=1
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).Range.InsertAfter theArray(2,j)
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).Range.ParagraphFormat.alignment=1
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).Range.InsertAfter FormatCurrency(theArray(3,j))
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).Range.ParagraphFormat.alignment=2
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter theArray(4,j)
    'objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter Chr(10)
    objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.ParagraphFormat.alignment=1
    tabRow = tabRow + 1
    Next' objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.ParagraphFormat.alignment=1objWordDoc.Application.ActiveDocument.SaveAs "tempSample.doc", 0,False,"",True,"",False,False,False, False,False
    End Sub
    </script>
      

  3.   

    生成Excel文件打印,有安全提示,需客户端装有Excel,IE6通过。<HTML>
    <BODY>
    Press the button to start Excel and display quarterly data.
    <SCRIPT LANGUAGE="VBScript">
    Function CreateNamesArray()
    ' Create an array to set multiple values at once.
      Dim saNames(5, 2)
      saNames(0, 0) = "John"
      saNames(0, 1) = "Smith"
      saNames(1, 0) = "Tom"
      saNames(1, 1) = "Brown"
      saNames(2, 0) = "Sue"
      saNames(2, 1) = "Thomas"
      saNames(3, 0) = "Jane"
      saNames(3, 1) = "Jones"
      saNames(4, 0) = "Adam"
      saNames(4, 1) = "Johnson"
      CreateNamesArray = saNames
    End Function
    </SCRIPT><SCRIPT LANGUAGE="JScript"> 
    function AutomateExcel()
    {
       // Start Excel and get Application object.
          var oXL = new ActiveXObject("Excel.Application");
           
          oXL.Visible = true;
          
       // Get a new workbook.
          var oWB = oXL.Workbooks.Add();
          var oSheet = oWB.ActiveSheet;
             
       // Add table headers going cell by cell.
          oSheet.Cells(1, 1).Value = "First Name";
          oSheet.Cells(1, 2).Value = "Last Name";
          oSheet.Cells(1, 3).Value = "Full Name";
          oSheet.Cells(1, 4).Value = "Salary";
             
       // Format A1:D1 as bold, vertical alignment = center.
          oSheet.Range("A1", "D1").Font.Bold = true;
          oSheet.Range("A1", "D1").VerticalAlignment =  -4108; //xlVAlignCenter
             
       // Create an array to set multiple values at once.   // Fill A2:B6 with an array of values (from VBScript).
          oSheet.Range("A2", "B6").Value = CreateNamesArray();
         
       // Fill C2:C6 with a relative formula (=A2 & " " & B2).
          var oRng = oSheet.Range("C2", "C6");
          oRng.Formula = "=A2 & \" \" & B2";
             
       // Fill D2:D6 with a formula(=RAND()*100000) and apply format.
          oRng = oSheet.Range("D2", "D6");
          oRng.Formula = "=RAND()*100000";
          oRng.NumberFormat = "$0.00";
             
       // AutoFit columns A:D.
          oRng = oSheet.Range("A1", "D1");
          oRng.EntireColumn.AutoFit();
             
       // Manipulate a variable number of columns for Quarterly Sales Data.
          DispalyQuarterlySales(oSheet);
            
       // Make sure Excel is visible and give the user control
       // of Excel's lifetime.
          oXL.Visible = true;
          oXL.UserControl = true;
    }
          
    function DispalyQuarterlySales(oWS)
    {
          var iNumQtrs, sMsg, iRet;    // Number of quarters to display data for.
          iNumQtrs = 4;
                   
        // Starting at E1, fill headers for the number of columns selected.
          var oResizeRange = oWS.Range("E1", "E1").Resize(1,iNumQtrs);
          oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\"";
             
        // Change the Orientation and WrapText properties for the headers.
          oResizeRange.Orientation = 38;
          oResizeRange.WrapText = true;
             
        // Fill the interior color of the headers.
          oResizeRange.Interior.ColorIndex = 36;
             
        // Fill the columns with a formula and apply a number format.
          oResizeRange = oWS.Range("E2", "E6").Resize(5,iNumQtrs);
          oResizeRange.Formula = "=RAND()*100";
          oResizeRange.NumberFormat = "$0.00";
             
        // Apply borders to the Sales data and headers.
          oResizeRange = oWS.Range("E1", "E6").Resize(6,iNumQtrs);
          oResizeRange.Borders.Weight = 2;  // xlThin
             
        // Add a Totals formula for the sales data and apply a border.
          oResizeRange = oWS.Range("E8", "E8").Resize(1,iNumQtrs);
          oResizeRange.Formula = "=SUM(E2:E6)";
        // 9 = xlEdgeBottom      
          oResizeRange.Borders(9).LineStyle = -4119; //xlDouble
          oResizeRange.Borders(9).Weight = 4; //xlThick
             
        // Add a Chart for the selected data.
          oResizeRange = oWS.Range("E2:E6").Resize(5,iNumQtrs);
          var oChart = oWS.Parent.Charts.Add();
          oChart.ChartWizard(oResizeRange, -4100, null, 2);  // -4100 = xl3dColumn
          oChart.SeriesCollection(1).XValues = oWS.Range("A2", "A6");
          for (iRet = 1; iRet <= iNumQtrs; iRet++) {
             oChart.SeriesCollection(iRet).Name = "=\"Q" + iRet + "\"";
          }
          oChart.Location(2, oWS.Name); // 2 = xlLocationAsObject
             
        // Move the chart so as not to cover your data.
          oWS.Shapes("Chart 1").Top = oWS.Rows(10).Top;
          oWS.Shapes("Chart 1").Left = oWS.Columns(2).Left;
    }
    </SCRIPT>
    <P><INPUT id=button1 type=button value="Start Excel" 
              onclick="AutomateExcel"></P>
    </BODY>
    </HTML>
      

  4.   

    to  pcai(小心漏电),
    你这种能做出复杂的报表吗?
      

  5.   

    谢谢楼上几位。to hotenM(五月飓风),
    常用的有哪些第三方控件? 各有什么特点?
      

  6.   

    我觉得这样的组合也是可行的
    java -xml - pdf
    将数据存储在xml中,生成pdf文件
      

  7.   

    用FOP生成pdf文件,再打印(中间需要先生成*.fo文件,然后再转换成PDF文件)
      

  8.   

    用PDF呀,www.pdflib.com上有for java的API。
      

  9.   

    我们恰巧正在做,xml数据岛,数据绑定生成页面,IE打印,可解大部分报表。
    二维计算统计报表(指定个别行列计算)手工做,IE打印。但IE打印不能实现连续打印。
      

  10.   

    可以用report craft (日本Canon的产品) 或者 crystal report(clear) 挺好用的,都可实现WEB打印而且客户端不需要做任何配置,
      

  11.   

    我做了一个纯WEB打印及报表设计器,客户端无需任何配置,也不需下载组件,只需IE就够了。服务器端用纯JAVA做的。
    详细参见:
    http://www.fcsoft.com.cn而且提供100%的源程序。
      

  12.   

    我现在使用pdf,效率差的要死,每有比较好的办法。我也想知道。不过用pdf可以作。
      

  13.   

    http://ygyuan.3322.net/
    http://ygyuan.onchina.net/袁飞打印预览控件
    http://www.yueliangwan.com.cn/yf/yfproduct/yfPrint3.0/PrintView.htm
    http://www.yueliangwan.com.cn/yf/yfproduct/yfPrint3.0/demo.htm
      

  14.   

    大家访问访问http://www.inetsoft.com
    这家公司的产品挺好的。
      

  15.   

    真正处理web界面处理报表打印,不错用pdf,用java一定要用iText
    我们就是这样做的,很漂亮。记住:是 iText 不是 pdflib!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!www.sf.net上面有Open Source 的iText
      

  16.   

    pcai(小心漏电)讲的这种方法比较好用,非常感谢!但不知道怎么设置其中的列宽(width),不知道该加在什么地方?怎么加?再次感谢各位的讨论!!
      

  17.   

    e表将Excel功能和数据库技术融为一体。既能实现自由表格的输入,公式计算。又能实现信息管理系统中的查询统计报表的功能。 
       e表是一个报表设计工具软件,用来设计在互联网环境下即在浏览器中运行的报表。 它是由一个报表模版的设计工具和报表内容的展现工具两部分组成。使用它可以大大提高查询统计报表的开发速度,对于象资产负债表之类 的自由表格更是易如反掌。
       e表主要采用Java Xml编写而成,因此具有良好的跨平台性。详情参见:http://www.fcsoft.com.cn:8080/webreport/help/index.html
      

  18.   

    e表和那个webprint要给钱的耶!
      

  19.   

    我们公司就是用的Cell插件(客户端会自动下载哦),有CA认证,效果很好。
    演示 :   http://211.100.17.199/test/CellDemo.htm
    我页面上的文件是用华表设计的,无需任何编程,太爽了。
    可以直接插入数据或循环插入数据,不过涉及机密,所以不能公布。
    出品商:用友华表 www.cellsoft.cc
     
      

  20.   

    目前的版本已经支持PDF格式的输出和完美的Excel双向导入导出功能,用友强大的研发能力,如果你是正规企业级应用,应该是相当不错的。
    我刚用它开发完一个海外项目,外国人对它赞不绝口的。
      

  21.   

    : EtCell(昂利万报表) ,你在做广告哦,如果是不要钱的,还是不错的哦
      

  22.   

    我的也是广告,可以和所有的解决方案比一比,大家切磋切磋!不过,一分
    钱一分货,只要免费的,别人的劳动得不到尊重,自己的劳动价值可能
    也很难体现,大家都要免费!纯java的web报表开发工具:Style Report,可在http://www.inetsoft.com
    下载试用版;Style Report的功能非常强大,在被称为软件业的奥斯卡奖的2002年度的JDJ评选当中,名列Best Java Reporting Tools的第一位。有兴趣
    者可以发mail给[email protected]和inetsoft在北京的销售部联系