簡體   English   中英

如何通過鏈接而不是圖像文件通過Spreadsheet Light將圖片插入Excel電子表格?

[英]How can I insert a picture into an Excel spreadsheet with Spreadsheet Light from a link rather than an image file?

使用Spreadsheet Light可以很容易地將圖片添加到表格中,如下所示:

SLPicture logoPic = new SLPicture(@"C:\Platypus\DuckbillsUnlimited.png");
logoPic.SetPosition(0, 13);
sl.InsertPicture(logoPic);

...但是我想在URL而不是文件中使用圖像。 如何完成的?

我嘗試直接在SLPicture的構造函數中使用圖像URL,但是不支持。 您可以使用以下解決方法:

  1. 將圖像文件下載到一個臨時位置。
  2. 從臨時位置使用下載的文件。

對示例代碼的修改如下所示:

WebClient client = new WebClient();
client.DownloadFile(new Uri(url), @"C:\Platypus\DuckbillsUnlimited.png");

SLPicture pic = new SLPicture(@"C:\Platypus\DuckbillsUnlimited.png");
logoPic.SetPosition(0, 13);
sl.InsertPicture(logoPic);

不知道是否還有其他方法,但這絕對可行! 打開其他建議!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM