原創(chuàng)|使用教程|編輯:張瑩心|2021-10-27 09:38:01.767|閱讀 234 次
概述:自 VintaSoft Imaging .NET SDK 10.1 版以來,可以以編程方式編輯現(xiàn)有的 DOCX 和 XLSX 文檔。本文使用此功能創(chuàng)建一個(gè)簡(jiǎn)單且易于定制的 XLSX 文檔格式的價(jià)目表生成器。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
VintaSoftImaging.NET SDK是一個(gè)為.NET開發(fā)人員開發(fā)的,強(qiáng)大而易于使用的圖像工具包。它可以讓你加載、查看、處理、打印和保存數(shù)字圖像,可將它們轉(zhuǎn)換為不同的圖像格式,可用多種TIFF和動(dòng)態(tài)GIF文件提高您的工作效率。
通常,價(jià)目表是包含商品或服務(wù)信息(描述、照片、數(shù)量、價(jià)格)的表格。對(duì)于此類表的表示非常適合 XLSX 格式。
自 VintaSoft Imaging .NET SDK 10.1 版以來,可以以編程方式編輯現(xiàn)有的 DOCX 和 XLSX 文檔。可以使用此功能創(chuàng)建一個(gè)簡(jiǎn)單且易于定制的 XLSX 文檔格式的價(jià)目表生成器。
執(zhí)行以下步驟以創(chuàng)建 XLSX 文檔格式:
價(jià)目表生成器:
// 使用此代碼的項(xiàng)目必須引用以下程序集: // - Vintasoft.Imaging // - Vintasoft.Imaging.Office.OpenXml /// <summary> /// 生成基于 XLSX 文檔模板的 XLSX 價(jià)目表。 /// </summary> public static void GenerateXlsxPricelist() { //創(chuàng)建XLSX文檔編輯器和使用文件“Pricelist_template.xlsx”作為文檔模板 使用(Vintasoft.Imaging.Office.OpenXml.Editor。XlsxDocumentEditor編輯器= 新Vintasoft.Imaging.Office.OpenXml.Editor。XlsxDocumentEditor(“Pricelist_template.xlsx” )) { // 生成測(cè)試價(jià)目表數(shù)據(jù) PriceListItem[] testData = GetTestData(); // 填寫價(jià)目表數(shù)據(jù) FillPricelistData(editor, testData); // 將價(jià)格表保存到 XLSX 文檔 editor.Save( " Pricelist.xlsx " ); } } /// <summary> /// 使用 XLSX 文檔編輯器填充價(jià)目表數(shù)據(jù)。 /// </summary> /// <param name="documentEditor">DOCX 文檔編輯器。</param> /// <param name="pricelistData">價(jià)目表數(shù)據(jù)。</param> private static void FillPricelistData ( Vintasoft.Imaging.Office.OpenXml.Editor。XlsxDocumentEditor文檔編輯器, PriceListItem[] pricelistData) { // 在文檔中設(shè)置當(dāng)前日期 documentEditor.Body[ "[date]" ] = System. 日期時(shí)間.Now.ToShortDateString(); // 獲取文檔 Vintasoft.Imaging.Office.OpenXml.Editor 中的第一張工作表。XlsxDocumentSheet sheet = documentEditor.Sheets[0]; // 獲取文檔 Vintasoft.Imaging.Office.OpenXml.Editor 中的模板行。XlsxDocumentSheetRow templateRow = sheet.FindRow( "[n]" ); int itemNumber = 1; // 對(duì)于價(jià)目表中的每一項(xiàng) foreach (PriceListItem item in pricelistData ) { // 復(fù)制模板行并在模板行后插入副本 Vintasoft.Imaging.Office.OpenXml.Editor. XlsxDocumentSheetRow currentRow = templateRow; templateRow =(Vintasoft.Imaging.Office.OpenXml.Editor。XlsxDocumentSheetRow)templateRow.InsertCopyAfterSelf(); // 填充當(dāng)前行的數(shù)據(jù) currentRow.FindCell( "[n]" ).Number = itemNumber; currentRow.FindCell( "[產(chǎn)品]" ).Text = item.Product; currentRow.FindCell( "[價(jià)格]" ).Number = item.Price; // 獲取當(dāng)前行中存儲(chǔ)產(chǎn)品圖片的圖片對(duì)象 Vintasoft.Imaging.Office.OpenXml.Editor. OpenXmlDocumentImage image = sheet.FindImages(currentRow)[0]; // 如果產(chǎn)品有圖片 if (! string .IsNullOrEmpty(item.ImageId)) { 在圖像對(duì)象//集產(chǎn)品圖像 使用(Vintasoft.Imaging。VintasoftImage productImage =新Vintasoft.Imaging。VintasoftImage(item.ImageId)) image.SetImage(productImage, true ); } 別的 { // 從當(dāng)前行移除圖像對(duì)象 圖像.移除(); } 項(xiàng)目編號(hào)++; } // 從結(jié)果文檔中刪除模板行 templateRow.Remove(); } /// <summary> /// 返回價(jià)目表測(cè)試數(shù)據(jù)。 /// </summary> /// <returns>價(jià)格表測(cè)試數(shù)據(jù)。</returns> public static PriceListItem[] GetTestData() { return new PriceListItem[] { new PriceListItem( "VintaSoft Imaging .NET SDK, Developer license for Desktop PCs" , "vsimaging-icon.png" , 219.95f), new PriceListItem( "VintaSoft Imaging .NET SDK, Developer license for Servers" , "vsimaging-icon.png" , 549.95f), new PriceListItem( "VintaSoft Imaging .NET SDK, Site license for Desktop PCs" , "vsimaging-icon.png" , 659.95f), new PriceListItem( "VintaSoft Imaging .NET" SDK,服務(wù)器站點(diǎn)許可”,“vsaging-icon.PNG", 1649.95f), new PriceListItem( "VintaSoft Imaging .NET SDK, Single Server license" , "vsimaging-icon.png" , 164.95f), new PriceListItem( "VintaSoft Annotation .NET Plug-in, Site license for Desktop PCs" , "vsannotation-icon.png" , 449.95f), new PriceListItem( "VintaSoft Office .NET Plug-in, Site license for Desktop PCs" , "vsoffice-icon.png" , 569.95f), new PriceListItem( "VintaSoft PDF .NET Plug-in (Reader+Writer), 臺(tái)式電腦站點(diǎn)許可" , "vspdf-icon.png" , 1499.95f),新PriceListItem( "VintaSoft PDF .NET Plug-in (Reader+Writer+VisualEditor), Site license for Desktop PCs" , "vspdf-icon.png" ,2999.95f), new PriceListItem( "VintaSoft JBIG2 .NET Plug-in, Site臺(tái)式電腦許可證” , “vsjbig2-icon.png” ,1139.95f), new PriceListItem( “VintaSoft JPEG2000 .NET 插件, 臺(tái)式電腦站點(diǎn)許可證” , “vsjpeg2000-icon.png” , 689.95f), new PriceListItem( "VintaSoft Document Cleaup .NET Plug-in, Site license for Desktop PCs" , "vsdoccleanup-icon.png" , 569.95f), 新的價(jià)目表項(xiàng)目("VintaSoft OCR .NET 插件,臺(tái)式電腦的站點(diǎn)許可證","vsocr-icon.png",509.95f), 新的PriceListItem( "VintaSoft DICOM .NET 插件(編解碼器+MPR),臺(tái)式機(jī)的站點(diǎn)許可證) " , "vsdicom-icon.png" , 1199.95f), new PriceListItem( "VintaSoft Forms Processing .NET Plug-in, Site license for Desktop PCs" , "vsformsprocessing-icon.png" , 509.95f), new PriceListItem( " VintaSoft Barcode .NET SDK (1D+2D Reader+Writer), 臺(tái)式電腦站點(diǎn)許可" , "vsbarcode-icon.png" , 1379.95f), 新的價(jià)目表項(xiàng)目("VintaSoft Twain .NET SDK, Developer license" , "vstwain-icon.png" , 179.95f), new PriceListItem( "VintaSoft Twain .NET SDK, Site license" , "vstwain-icon.png" , 539.95f), new PriceListItem( "VintaSoft Twain .NET SDK, Single URL license" , "vstwain-icon.png" , 149.95f), new PriceListItem( "VintaSoft Twain ActiveX, Developer license" , "vstwain-icon.png" , 99.95f), new PriceListItem( "VintaSoft Twain ActiveX, 站點(diǎn)許可證" , "vstwain-icon.png" , 299.95f), new PriceListItem( "VintaSoft Twain ActiveX, Single URL license" , "vstwain-icon.png" , 119.95f) }; } /// <summary> /// 代表一個(gè)價(jià)目表項(xiàng)目。 /// </summary> 公共 類PriceListItem { /// <summary> /// 初始化 <see cref="PriceListItem"/> 類的新實(shí)例。 /// </summary> /// <param name="product">產(chǎn)品名稱。</param> /// <param name="imageId">圖像ID。</param> /// <param name="price">產(chǎn)品價(jià)格。</param> public PriceListItem( string product, string imageId, float price) { 產(chǎn)品 = 產(chǎn)品; ImageId = imageId; 價(jià)格 = 價(jià)格; } /// <summary> /// 獲取產(chǎn)品名稱。 /// </summary> 公共 字符串產(chǎn)品; /// <summary> /// 獲取圖像 ID。 /// </summary> 公共 字符串ImageId; /// <summary> /// 獲取產(chǎn)品價(jià)格。 /// </summary> 公開 浮動(dòng)價(jià)格; }
購(gòu)買最新正版授權(quán)!""
慧都年終盛典火爆開啟,一年僅一次的最強(qiáng)促銷,十八周年盛“惠”不容錯(cuò)過!!優(yōu)惠詳情點(diǎn)擊查看>>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn