翻譯|使用教程|編輯:張瑩心|2021-11-10 10:35:33.710|閱讀 487 次
概述:有時在完成 Excel 工作簿后,您可能需要用更好的圖片替換一些現有圖片,以使工作簿更具吸引力和說服力。在本教程中,您將學習如何使用Spire.XLS for .NET替換Excel 中的圖片。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.XLS for .NET 是一款專業的 .NET Excel 組件, 它可以用在各種.NET 框架中,包括 .NET Core、ASP.NET 和 Windows Forms 等相關的.NET 應用程序。
有時在完成 Excel 工作簿后,您可能需要用更好的圖片替換一些現有圖片,以使工作簿更具吸引力和說服力。在本教程中,您將學習如何使用Spire.XLS for .NET替換Excel 中的圖片。
*這么優秀的國產工具怎能錯過呢!在線下單專享“一口價”,立即購買!想要獲取更多福利的朋友可以哦~
在 Excel 中替換圖片
以下是使用 Spire.XLS for .NET 將一張圖片替換為另一張圖片的詳細步驟。
using Spire.Xls; using Spire.Xls.Collections; using System.Drawing; namespace ReplacePictureinExcel { class Program { static void Main(string[] args) { //Create a Workbook instance Workbook workbook = new Workbook(); //Load the Excel file workbook.LoadFromFile (“Input.xls”); //Get the first sheet Worksheet sheet = workbook.Worksheets[0]; //Get Excel picture collection PicturesCollection pictureCollection = sheet.Pictures; //Get the first picture from the collection ExcelPicture excelPicture = pictureCollection[0]; // Creates an Image from the specified file. excelPicture.Picture = Image.FromFile (image); //Save the document workbook.SaveToFile("ReplaceImage.xlsx", ExcelVersion.Version2013); } } }VB.NET
Imports Spire.Xls Imports Spire.Xls.Collections Imports System.Drawing Namespace ReplacePictureinExcel Class Program Private Shared Sub Main(args As String()) 'Create a Workbook instance Dim workbook As New Workbook() 'Load the Excel file workbook.LoadFromFile(Input.xls) 'Get the first sheet Dim sheet As Worksheet = workbook.Worksheets(0) 'Get Excel picture collection Dim pictureCollection As PicturesCollection = sheet.Pictures 'Get the first picture from the collection Dim excelPicture As ExcelPicture = pictureCollection(0) ' Creates an Image from the specified file. excelPicture.Picture = Image.FromFile(image) 'Save the document workbook.SaveToFile("ReplaceImage.xlsx", ExcelVersion.Version2013) End Sub End Class End Namespace
原始文件:
生成的文件:
慧都是E-iceblue官方友好合作伙伴,如果您對spire.xls,可以了解具體授權價格和使用機制
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn