我正在尝试从数据库动态构建 word 文档(我正在使用 CFC 进行查询处理)。我的努力是成功的,但我只能复制英文文档。但是,我的应用程序使用的是希腊语。
当我尝试构建包含希腊字符的文档时,输出如下所示??????????????????
:我尝试了很多东西,但没有任何效果。奇怪的是,当我使用相同的 CFC 进行 PDF 复制时,希腊字符输出正确。
cfm 文件:
<cfheader name="Content-Disposition" value="inline; filename=Save-Print.doc" charset="utf-8">
<cfcontent type="application/msword">
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Print</title>
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Compatibility>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<![endif]-->
<!--[if supportFields]>
<div style="mso-element:header" id="lala">
<p class=MsoHeader><span style="color:red">
<![endif]-->
<style>
<!--
@page Section1
{
size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;
mso-header:url("http://localhost:8500/BookLedger_Final/resources/cfScripts/Header.html") h1;
mso-footer:url("http://localhost:8500/BookLedger_Final/resources/cfScripts/Header.html") f1;
}
div.Section1 {page:Section1;}
p.MsoHeader {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #333;
}
p.MsoFooter {
}
-->
</style>
</head>
<body>
<cfif not IsDefined("URL.id")>
<cfelseif not IsDefined("URL.model")>
</cfif>
<!--- Get print details --->
<cfinvoke
component="Print"
method="myPrint"
returnvariable="getMember"
id="#URL.id#"
model="#URL.model#">
<div class=Section1>
<cfoutput query="getMember">
<b id="lala">#Title#</b>
<p style="color:##1c1c1c"><i>#Body#</i></p>
</cfoutput>
</div>
</body>
</html>
cfc 文件:
<cfcomponent>
<cffunction name="myPrint" access="remote" returntype="query" output="no">
<cfargument name="id" default="0" required="false" type="numeric">
<cfargument name="model" default="" required="false" type="any">
<cfset model = #ARGUMENTS.model#>
<cfif model EQ "member">
<cfquery name="getMember" datasource="rental">
SELECT CONCAT(rental.members.firstname,' ',rental.members.lastname) AS 'Title',rental.members.biog AS 'Body'
FROM rental.members
WHERE rental.members.id = #ARGUMENTS.id#
AND rental.members.model = "#ARGUMENTS.model#"
</cfquery>
<!---<cfset queryToString = serializeJson(getMember)>
<cfset strippedQuery = REReplace(queryToString,'<[^>]*>','','all')>--->
<cfreturn getMember>
<cfelseif model EQ "new_member">
<cfquery name="getMember" datasource="rental">
SELECT CONCAT(rental.new_members.firstname,' ',rental.new_members.lastname) AS 'Title',rental.new_members.biog AS 'Body'
FROM rental.new_members
WHERE rental.new_members.id = #ARGUMENTS.id#
AND rental.new_members.model = "#ARGUMENTS.model#"
</cfquery>
<cfreturn getMember>
<cfelseif model EQ "book">
<cfquery name="getMember" datasource="rental">
SELECT rental.books.title AS 'Title',rental.books.description AS 'Body'
FROM rental.books
WHERE rental.books.id = #ARGUMENTS.id#
AND rental.books.model = "#ARGUMENTS.model#"
</cfquery>
<cfreturn getMember>
<cfelseif model EQ "journal">
<cfquery name="getMember" datasource="rental">
SELECT rental.journals.title AS 'Title',rental.journals.description AS 'Body'
FROM rental.journals
WHERE rental.journals.id = #ARGUMENTS.id#
AND rental.journals.model = "#ARGUMENTS.model#"
</cfquery>
<cfreturn getMember>
<cfelseif model EQ "cd">
<cfquery name="getMember" datasource="rental">
SELECT rental.cd.title AS 'Title',rental.cd.description AS 'Body'
FROM rental.cd
WHERE rental.cd.id = #ARGUMENTS.id#
AND rental.cd.model = "#ARGUMENTS.model#"
</cfquery>
<cfreturn getMember>
</cfif>
</cffunction>
</cfcomponent>