| |

VerySource

 Forgot password?
 Register
Search
View: 1054|Reply: 9

jsp call excel print how to set page horizontally with code

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 United States

Post time: 2020-1-17 22:20:01
| Show all posts |Read mode
Now do a project, encountered printing problems, please enlighten me, hurry.
I clicked on the "print" link with jsp and connected to an excel-generated jsp page. Automatic horizontal and vertical setting according to the data. I don't know the relevant attributes, please enlighten me. Thank you
Reply

Use magic Report

0

Threads

18

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-24 09:27:01
| Show all posts
Help you
Reply

Use magic Report

3

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-24 14:36:01
| Show all posts
<% @ page contentType = "application / vnd.ms-excel"%>
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-10 00:45:01
| Show all posts
Ask the same
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-10 09:30:01
| Show all posts
Bangding, follow
Reply

Use magic Report

0

Threads

16

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-8-10 11:00:01
| Show all posts
Export to excel printing
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   Response.Clear();
   Response.Buffer = true;
   
   Response.AppendHeader("Content-Disposition","attachment;filename=Borrow.xls");
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");

   Response.ContentType = "application/ms-excel";
   this.EnableViewState = false;
   
   System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
   System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
   System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
   
   Table3.RenderControl(oHtmlTextWriter);

   Response.Charset="gb2312";
   Response.Write(oStringWriter.ToString());
   Response.End();
  }
Reply

Use magic Report

0

Threads

16

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-8-10 11:15:01
| Show all posts
Control "Vertical", "Horizontal" and "Page margins."
(1) <script defer>
function SetPrintSettings() {
 // - advanced features
 Factory.printing.SetMarginMeasure(2) // measure margins in inches
 Factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
 Factory.printing.printer = "HP DeskJet 870C"
 Factory.printing.copies = 2
 Factory.printing.collate = true
 Factory.printing.paperSize = "A4"
 Factory.printing.paperSource = "Manual feed"

 // - basic features
 Factory.printing.header = "This is MeadCo"
 Factory.printing.footer = "Advanced Printing by scriptX"
 Factory.printing.portrait = false
 Factory.printing.leftMargin = 1.0
 Factory.printing.topMargin = 1.0
 Factory.printing.rightMargin = 1.0
 Factory.printing.bottomMargin = 1.0
}
</script>

(2)
<script language="javascript">
  Function printsetup(){
  // Print page setup
  Wb.execwb(8,1);
  }
  Function printpreview(){
  // Print page preview
    
  Wb.execwb(7,1);
     
    
  }

  Function printit()
  {
  If (confirm("Are you sure to print?'')) {
  Wb.execwb(6,6)
  }
  }
  </script>
</head>
<body>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"

height=0 id=wb name=wb width=0></OBJECT>
<input type=button name=button_print value="print"

onclick="javascript:printit()">
<input type=button name=button_setup value="print page setup"

onclick="javascript:printsetup();">
<input type=button name=button_show value="print preview"

onclick="javascript:printpreview();">
<input type=button name=button_fh value="close"

onclick="javascript:window.close();">
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-10 12:15:01
| Show all posts
mark
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-10 12:30:02
| Show all posts
Well, js calls the print control of ie
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-10 12:45:01
| Show all posts
attention
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list