输出EXCEL文件的通用函数,很实用

本文介绍了一个使用ASP编写的简单程序,该程序能够将SQL查询结果导出为EXCEL文件。仅需设置SQL查询语句及输出文件名即可实现。
下面这段小程序,用于把一个SQL的SELECT查询出的结果输出为EXCEL格式文件,这个程序你只要设好用于取得一个记录集的SQL的SELECT查询语句和一个文件名,程序就能输出EXCEL格式文件了,这个程序一共由三个文件构成,第一个文件的文件名为:toexcel.asp是主文件,内容如下:
<% 
set conn=opendb("EMSC")
'前面是设置数据源并链接到数据库,请自行书写相关语句,此处略过 

sql
="select * from sys_user" '这里是要输出EXCEL的查询语句,如 "SESECT * FORM CAI WHERE 性别='女'" 
filename="excel.xls" ' 要输出的EXCEL文件的文件名, 你只要改以上两句就行了,其它的都不要改. 

'你只要修改以上两变量就行了.其它的我都做好了. 

call toexcel(FILENAME,sql) 
set conn=nothing 

function ReadText(FileName) '这是一个用于读出文件的函数 
set adf=server.CreateObject("Adodb.Stream"
with adf 
.Type
=2 
.LineSeparator
=10 
.Open 
.LoadFromFile (server.MapPath(FileName)) 
.Charset
="GB2312" 
.Position
=2 
ReadText
=.ReadText 
.Cancel() 
.Close() 
end with 
set ads=nothing 
end function 

sub SaveText(FileName,Data) '这是一个用于写文件的函数 
set fs= createobject("scripting.filesystemobject"
set ts=fs.createtextfile(server.MapPath(FileName),true
ts.writeline(data) 
ts.close 
set ts=nothing 
set fs=nothing 
end sub 

sub toexcel(filename,sql) '这是一个根据SQL语句和FILENAME生成EXCEL文件 
Set rs=Server.CreateObject("ADODB.RecordSet"
rs.Open sql,conn,
1,3 
TOEXCELLR
="<table width='100%'><tr >" 
set myfield=rs.fields 
dim fieldname(50
for i=0 to myfield.count-1 
toexcellr
=toexcellr&"<td class=xl24>"&MYFIELD(I).NAME&"</td>" 
fieldname(i)
=myfield(i).name 
if myfield(i).type=135 then datename=datename&myfield(i).name&"," 
next 
toexcellr
=toexcellr&"</tr>" 
do while not rs.eof 
toexcellr
=toexcellr&"<tr>" 
for i=0 to myfield.count-1 
if instr(datename,fieldname(i)&",")<>0 then 
if not isnull(rs(fieldname(i))) then 
TOEXCELLR
=TOEXCELLR&"<td class=xl25 ><p align='left'>"&formatdatetime(rs(fieldname(i)),2)&"</p></td>" 
else 
TOEXCELLR
=TOEXCELLR&"<td class=xl25 ><p align='left'> </p></td>" 
end if 
else 
TOEXCELLR
=TOEXCELLR&"<td class=xl24 >"&rs(fieldname(i))&"</td>" 
end if 
next 
toexcellr
=toexcellr&"</tr>" 
rs.movenext 
loop 
toexcellr
=toexcellr&"</table>" 
tou
=readtext("tou.txt"
di
=readtext("di.txt"
toexcellr
=tou&toexcellr&di 
call savetext(filename,toexcellr) 
end sub 
%> 
<html> 
<head> 
<meta http-equiv="refresh" content="3;URL=<%=filename%>"> 
<meta http-equiv="Content-Language" content="en-us"> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>正在生成EXLCE文件</title> 
</head> 
<BODY> 
正在生成EXLCE文件
</BODY> 
</HTML> 

********第二个文件名为:di.txt 内容如下:

<table x:str border=0 cellpadding=0 cellspacing=0 width=288 style='border-collapse:
collapse;table-layout:fixed;width:216pt'>
<![if supportMisalignedColumns]>
<tr height=0 style='display:none'>
<td width=72 style='width:54pt'></td>
<td width=72 style='width:54pt'></td>
<td width=72 style='width:54pt'></td>
<td width=72 style='width:54pt'></td>
</tr>
<![endif]>
</table>

************第三个文件的文件名为:tou.TXT 内容如下:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 9">
<link rel=File-List href="./222.files/filelist.xml">
<link rel=Edit-Time-Data href="./222.files/editdata.mso">
<link rel=OLE-Object-Data href="./222.files/oledata.mso">
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>xky</o:Author>
<o:LastAuthor>xky</o:LastAuthor>
<o:Created>2002-05-27T17:51:00Z</o:Created>
<o:LastSaved>2002-06-22T10:03:03Z</o:LastSaved>
<o:Company>zydn</o:Company>
<o:Version>9.2812</o:Version>
</o:DocumentProperties>
<o:OfficeDocumentSettings>
<o:DownloadComponents/>
<o:LocationOfComponents HRef="file:///E:/msowc.cab"/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:bottom;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:常规;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
.xl24
{mso-style-parent:style0;
border:.5pt solid windowtext;}
.xl25
{mso-style-parent:style0;
mso-number-format:"Long Date";
text-align:left;
border:.5pt solid windowtext;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>225</x:DefaultRowHeight>
<x:Print>
<x:ValidPrinterInfo/>
<x:PaperSizeIndex>9</x:PaperSizeIndex>
<x:HorizontalResolution>-3</x:HorizontalResolution>
<x:VerticalResolution>0</x:VerticalResolution>
</x:Print>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveRow>24</x:ActiveRow>
<x:ActiveCol>5</x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>Sheet2</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>225</x:DefaultRowHeight>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>Sheet3</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>225</x:DefaultRowHeight>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>6600</x:WindowHeight>
<x:WindowWidth>12000</x:WindowWidth>
<x:WindowTopX>0</x:WindowTopX>
<x:WindowTopY>1395</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>

<body link=blue vlink=purple>

转载于:https://www.cnblogs.com/Athrun/archive/2008/03/27/1126248.html

【源码免费下载链接】:https://renmaiwang.cn/s/os2te 大整数乘法是计算机科学中的一个重要领域,特别是在算法设计和数学计算中有着广泛应用。它涉及到处理超过标准整型变量范围的数值运算。在C++编程语言中,处理大整数通常需要自定义数据结构和算法,因为内置的`int`、`long long`等类型无法满足大整数的存储和计算需求。以下是对这个主题的详细阐述:1. **大整数数据结构**: 在C++中,实现大整数通常采用数组或链表来存储每一位数字。例如,可以使用一个动态分配的数组,每个元素表示一个位上的数字,从低位到高位排列。这种数据结构允许我们方便地进行加减乘除等操作。2. **乘法算法**: - **暴力乘法**:最直观的方法是类似于小学的竖式乘法,但效率较低,时间复杂度为O(n^2)。 - **Karatsuba算法**:由Alexander Karatsuba提出,将两个n位数的乘法转化为三个较小的乘法,时间复杂度为O(n^1.585)。 - **Toom-Cook算法**:比Karatsuba更通用,通过多项式插值和分解进行计算,有不同的变体,如Toom-3、Toom-4等。 - **快速傅里叶变换(FFT)**:当处理的大整数可以看作是多项式系数时,可以利用FFT进行高效的乘法,时间复杂度为O(n log n)。FFT在数论和密码学中尤其重要。3. **算法实现**: 实现这些算法时,需要考虑如何处理进位、溢出等问题,以及如何优化代码以提高效率。例如,使用位操作可以加速某些步骤,同时要确保代码的正确性和可读性。4. **源代码分析**: "大整数乘法全解"的源代码应包含了上述算法的实现,可能还包括了测试用例和性能比较。通过阅读源码,我们可以学习如何将理论算法转化为实际的程序,并理解各种优化技巧。5. **加说明**: 通常,源代码附带的说明会解释
内容概要:本文详细介绍了一个基于Java与Vue技术栈的向量数据库语义检索与相似文档查重系统的设计与实现。系统通过集成BERT等深度学习模型将文本转化为高维语义向量,利用Milvus等向量数据库实现高效存储与近似最近邻检索,结合前后端分离架构完成从文档上传、向量化处理、查重分析到结果可视化的完整流程。项目涵盖需求分析、系统架构设计、数据库建模、API接口规范、前后端代码实现及部署运维等多个方面,并提供了完整的代码示例和模块说明,支持多格式文档解析、智能分段、自适应查重阈值、高亮比对报告生成等功能,具备高扩展性、安全性和多场景适用能力。; 适合人群:具备一定Java和Vue开发基础的软件工程师、系统架构师以及从事自然语言处理、知识管理、内容安全等相关领域的技术人员,尤其适合高校、科研机构、企业IT部门中参与智能文档管理系统开发的专业人员。; 使用场景及目标:①应用于学术论文查重、企业知识产权保护、网络内容监控、政务档案管理等需要高精度语义比对的场景;②实现深层语义理解下的文档查重,解决传统关键词匹配无法识别语义改写的问题;③构建可扩展、高可用的智能语义检索平台,服务于多行业数字化转型需求。; 阅读建议:建议读者结合提供的完整代码结构与数据库设计进行实践操作,重点关注文本向量化、向量数据库集成、前后端协同逻辑及安全权限控制等核心模块。在学习过程中应逐步部署运行系统,调试关键接口,深入理解语义检索与查重机制的工作原理,并可根据实际业务需求进行功能扩展与模型优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值