Create a PDF file with ASP

xiaoxiao2021-04-09  471

<% OPTION Explicit

Sub CheckxLDriver () ON Error ResMe Next

DIM VCONNSTRING DIM OCONN, OERR

'try to connect to file Nul: vconnstring =' driver = {Microsoft Excel Driver (* .xls)}; dbq = NUL: '

Set Oconn = CreateObject ('AdoDb.Connection') Oconn.open vconnstring

For Each Oerr in Oconn.errors 'When The Excel Driver Reports' Failure Creating File ',' Ten It Must Be Installed and Working ;-)) f err.nativeError = -5036 THEN EXIT SUB End If Next

RESPONSE.WRITE 'Provider or Driver NOT AVAILABLE. (RE-) Install MDAC.

'

Response.Write Hex & '' & Err.Description & 'FOR Each Oerr in Oconn.erroRors Response.write HEX (Oerr.Number) &' '& Oerr.nativeError &' '& Oerr.Description & '' Next Response.end

End Sub

Function getConnection (vconnstring) on ​​Error ResMe Next

Set getConnection = Server.createObject ('adoDb.connection') getConnection.Open vconnstring

If Err.Number <> 0 THEN SET GETCONNECTION = Nothing endiff

END FUNCTION

Function OptionTag (Vchoice, Vtrue) DIM VSELECTED

IF vtrue life vselected = 'SELECTED' END IF

OptionTag = ' & _ server.htmlencode (vchoice) &' '& vbcrlf

END FUNCTION

Function ischecked (vtrue) if vtrue kilnecked = 'checked' end if end function

Function BookOptions (VXLFile) DIM VSERVERFOLDER DIM OFS, OFOLDER, OFILE

DIM VSELECTED

vserverfolder = server.mappath ('.')

Set ofs = server.createObject ('scripting.filesystemObject') set ofolder = OFS.GETFOLDER (Vserveerfolder)

FOR Each Ofile IN Ofolder.Files IF Ofile.Type = 'Microsoft Excel Worksheet' Then vselected = (ofile.Name = vxlfile) BookOptions = BookOptions &_ OptionTag (ofile.name, vselected) end if next

Set ofolder = Nothing set OFS = Nothing

END FUNCTION

Function NamedRangeOptions (Oconn, VxlRange, vTableType) DIM OSCHEMARS DIM VSELECTED

NamedRangeOptions = OptionTag (Empty, EMPTY)

If TypeName (Oconn) = 'connection' Then Set Oschemars = Oconn.openschema (Adschematables)

Do While Not oSchemaRs.EOF If oSchemaRs ( 'TABLE_TYPE') = vTableType Then vSelected = (oSchemaRs ( 'TABLE_NAME') = vXlRange) NamedRangeOptions = NamedRangeOptions & _ OptionTag (oSchemaRs ( 'TABLE_NAME'), vSelected)

END IF

Oschemars.movenext loop

End if End Function

Function DataTable (Oconn, vxlrange, vxlhasheadings) on Error ResMe Next

'from oledbvbc.inc const db_e_errorsincommand = & h80040e14

Dim Ors, Ofield Dim vthtag, Vthendtag

IF vxlhasheadings the vthtag = '' vthendtag = '' else vthtag = '' vthendtag = ' endiff

DataTable = '

'

If TypeName (Oconn) = 'connection' Then set ics = Oconn.execute ('[' & vxlrange & ']')

If Oconn.errors.count> 0 Then for Each Oconnerr in Oconn.erroRORS IF OCONNERR.NUMBER = DB_E_ERRORSINCOMMAND THEN DATATABLE = DATATABLE & _ '

'For Each Ofield in Ors.fields DataTable = DataTable & vthtag & Ofield.Name & Vthendtag Next

DataTable = DATATABLE & ''

Do While Not Ors.eof DataTable = DataTable & '

'

For Each Ofield in Ors.fields DataTable = DataTable & '

No Such Range: ' & VXLRANGE & ' ' else datatable = dataable & _ '
' & opnerrr.description & ' ' end if next else data = dataable & '
' & Ofield.Value & '' Next

DataTable = DataTable & '' Ors.movenext Loop

END IF

SET ORS = Nothing Else

DataTable = DATATABLE & '

File Locked by Another Application Or OtherWise Not Accessible. Cannot Continue. ' end if

DataTable = DATATABLE & '' End Function

'--main -%> read excel </ title> <script language = javascript> <! - function xlbook_onchange (theform) {with (theform) {xlsheet.selectedIndex = 0; Xlsheet.disabled = true; xlnamedrange.selectedIndIndex = 0; xlnamedrange.disabled = true; xltped management.value = 'a: iv';}}</p> <p>Function Xlsheet_Onchange (theform) {with (theform) {xlnamedrange.selectedIndIndex = 0; xltyped management [xlsheet.Options [xlsheet.selected ".Text;}}</p> <p>function XlNamedRange_onchange (theForm) {with (theForm) {XlSheet.selectedIndex = 0; XlTypedRange.value = XlNamedRange.options [XlNamedRange.selectedIndex] .text;}} function XlTypedRange_onchange (theForm) {with (theForm) {XlSheet.selectedIndex = 0 XLnamedRange.selectedIndex = 0;}}</p> <p>// -> </ script> </ head> <body> <% DIM VXLFILE, VXLFILEPATH DIM VXLRANGE, VXLHASHEADINGS DIM VDISABED</p> <p>DIM VCONNSTRING DIM OCONN, OCONNERR</p> <p>Const adschematables = 20 'from adovbs.inc</p> <p>Checkxldriver 'make Sure IT IS WORKING</p> <p>vxlfile = request ('xlbook')</p> <p>IF vxlfile <> EMPTY THEN</p> <p>VxlRange = Request ('XLtypedRange')</p> <p>IF vxlrange = Empty Then vxlrange = 'a: iv' else vxlrange = replace (vxlrange, '!', '$') Endiff</p> <p>VXLHASHEADINGS = Request ('xlhasheadings ")</p> <p>'ESTABLISH Connection VxLFilePath = Server.mAppath (vxlfile) vConnstring =' driver = {Microsoft Excel Driver (* .xls)}; readonly = 1; DBQ = '&_ vxlfilepath</p> <p>Set OconN = getConnection (vconnstring)</p> <p>Else vdisabled = 'disabled' endiff</p> <p>%> <form name = myform method = 'post' action = '<% = request.servervariables (' script_name ')%>> <Table Border =' 1 'width =' 100%> <TR> <TH> Workbook: </ th> <TD> <select name = 'xlbook' language = javascript οnchange = 'return xlbook_onchange (myform)'> <% = BookOptions (vxlfile)%> </ select> </ td> <TD align = 'center'> Worksheet: </ td> <td> <select <% = vDisabled%> name = 'xlSheet' LANGUAGE = javascript οnchange = 'return XlSheet_onchange (MyForm)'> <% = NamedRangeOptions (oConn, vXlRange, 'SYSTEM Table ')%> </ select> </ td> </ tr> <tr> <tr> rge: </ th> <td> <input type =' text 'name =' xltypedRange 'language = javascript οnchange =' Return XLTYPEDRANGE_ONCHANGE (MyForm) 'value =' <% = vxlrange%>> </ td> <td align = 'center'> named ranging: </ td> <td> <select <% = vdisabled%> Name = ' XlnamedRange 'Language = JavaScript οnchange =' Return XLnamedRange_Onchange (MyForm) '> <% = NamedRangeOptions (Oconn, VxlRange,' Table ')%> </ select> </ td> </ TR> <TR> <TH> <P > </ th> <td colspan = '3'> <Input Type = 'CheckBox' Name = 'xlhasheadings' <% = ischecked (vxlhasheadings)%> Value = 'true'> show first row as column headings </ td> </ tr> <</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-133118.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="133118" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.044</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'w3dn2FYSyuqy_2BuQ9UdbBfJGSOmF2XcwhD9KkRRKpcIdXhUnZzaKFeKMGgcdx9NcKrauMXfj7qRPAYku6KsZkOw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>