我正在一家开发公司完成我的学习结束实习,我的任务是升级维护管理平台。我需要添加的功能之一是使用c#和publipostage库.dll生成发票作为单词格式,但是当我尝试运行我的代码时出现错误:PublipostageException
代码
public void GenererEtatFacture() {
int IdFacture = int.Parse(Request["IdFacture"]);
PublipostageLibrary.BLMoulinette publi = new PublipostageLibrary.BLMoulinette();
string conString = ConfigurationManager.ConnectionStrings["ConnCR"].ConnectionString;
publi.Cnxstrg = conString;
//try {
publi.OpenPubipostage(Server.MapPath(Path.Combine("/","bin/Structure.xml")));
// }catch(Exception e){
//Console.WriteLine(e.StackTrace);
// }
publi.SetReportParams("IdFacture", "" + IdFacture);
var x = publi.LireModele(Server.MapPath(Path.Combine("/","Doc/facture.htm")));
HttpContext.Response.ContentType = "application/msword";
HttpContext.Response.AddHeader("Content-Disposition", "attachment;filename=facture.doc");
HttpContext.Response.Charset = "utf-8";
HttpContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
HttpContext.Response.Write(publi.StrutureExplore().ToString());
HttpContext.Response.Flush();
HttpContext.Response.End();
}
}
structure.xml
<?xml version="1.0" standalone="yes" ?>
<Publipostage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://tempuri.org/Publipostage.xsd">
<NomModele>test Modele</NomModele>
<Separateur>
<![CDATA[<br clear="all" style='page-break-before:always'>]]>
</Separateur>
<Sections>
<Section>
<SectionName>Corps</SectionName>
<SectionPrincipale>true</SectionPrincipale>
<Datasource>select * from etatFacture</Datasource>
<RelationField></RelationField>
<SectionType>Texte</SectionType>
<Body></Body>
<Variables>
<Mappings>
<Variable>VRefFacture</Variable>
<FieldSource>RefFacture</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VNumBC</Variable>
<FieldSource>NumBC</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VNomComplet</Variable>
<FieldSource>NomComplet</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VAdresse</Variable>
<FieldSource>Adresse</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VIdFacture</Variable>
<FieldSource>IdFacture</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VTVA</Variable>
<FieldSource>TVA</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VTotalTH</Variable>
<FieldSource>TotalTH</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VTotalTTC</Variable>
<FieldSource>TotalTTC</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VMontantLettre</Variable>
<FieldSource>MontantLettre</FieldSource>
</Mappings>
</Variables>
<Header></Header>
<ReportParams>
<ReportParam>
<Field>IdFacture</Field>
<Value></Value>
<Type>Numerique</Type>
</ReportParam>
<ReportParam>
<Field>DateSystem</Field>
<Value></Value>
<Type>Date</Type>
</ReportParam>
</ReportParams>
</Section>
<Section>
<SectionName>VDescription</SectionName>
<SectionType>Tableau</SectionType>
<Body>
<![CDATA[ <tr>
<td>
<p><span>- VValeurDescription</span></p>
</td>
<td>
<p><span>- VQuantite</span></p>
</td>
<td>
<p><span>- VPrixUnitaire</span></p>
</td>
<td>
<p><span>- VPrixTotal</span></p>
</td>
</tr>
]]>
</Body>
<SectionPrincipale>false</SectionPrincipale>
<Datasource>Select * from DescriptionFacture</Datasource>
<Variables>
<Mappings>
<Variable>VValeurDescription</Variable>
<FieldSource>ValeurDescription</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VQuantite</Variable>
<FieldSource>Quantite</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VPrixUnitaire</Variable>
<FieldSource>PrixUnitaire</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VPrixTotal</Variable>
<FieldSource>PrixTotal</FieldSource>
</Mappings>
</Variables>
<Variables>
<Mappings>
<Variable>VIdFacture</Variable>
<FieldSource>IdFacture</FieldSource>
</Mappings>
</Variables>
<RelationField>
<SlaveField>IdFacture</SlaveField>
<SectionName>VDescription</SectionName>
<MasterInfo>
<MasterField>IdFacture</MasterField>
<SectionName>Corps</SectionName>
</MasterInfo>
</RelationField>
<Footer><![CDATA[</TABLE>]]></Footer>
<Header>
<![CDATA[<TABLE border=1>
<TR>
<TD>Désignation</TD>
<TD>QTE</TD>
<TD>PU / HT</TD
<TD>PT / HT</TD>
</TR>]]>
</Header>
</Section>
我搜索了这个错误,却一无所获。