我正在使用Docx.dll一個DOCX發電機。到目前爲止,我已經能夠將圖像和文本插入到文檔中。圖像和段落不對齊。我需要將圖像換文。我該怎麼做? 我看着它在谷歌和發現這個鏈接 Adding Images to Documents in Word 2007 by Using the Open XML SDK 2.0。代碼工作並創建word文檔,但docx文件未打開。如何包裝形式在圖像中的docx文件在C#
我如何在C#中自動換行「在前面的文字」?
public static DocX CreateDocumentFile(List<CompanyInfo> info)
{
DocX document = DocX.Load(@"C:\Users\newton.sheikh\Documents\Visual Studio 2010\Projects\MSOffice\OpenXML\OpenXML\RetailWrite.docx");
foreach (var companies in info)
{
Formatting fm = new Formatting();
/*Inserting Image*/
Novacode.Image img = document.AddImage(@"C:\Users\newton.sheikh\Documents\Visual Studio 2010\Projects\MSOffice\OpenXML\OpenXML\logos\slime.png");
Novacode.Paragraph companyLogo = document.InsertParagraph("");
Picture pic1 = img.CreatePicture();
companyLogo.InsertPicture(pic1, 0);
Novacode.Paragraph CompanyName = document.InsertParagraph(companies.Name.ToString());
CompanyName.StyleName = "COMPANY";
Novacode.Paragraph CompanyPosition = document.InsertParagraph(companies.Position.ToString());
CompanyPosition.StyleName = "posit";
Novacode.Paragraph CompanyDescription = document.InsertParagraph(companies.Description.ToString());
CompanyDescription.StyleName = "descrip";
Novacode.Paragraph blankPara = document.InsertParagraph(" ");
Novacode.Paragraph blankPara2 = document.InsertParagraph(" ");
}
return document;
}
您能否寄出您正在使用的代碼。請閱讀常見問題解答,瞭解如何發佈問題。 – Shail 2013-02-26 09:39:58
我已經添加了代碼。 – 2013-02-26 09:43:48