Visual Basic
19 TopicsExtract images from excel stored as Place in cell
Hello experts, I am trying to extract images from an Excel file using a C# program. My code successfully retrieves images that are placed over cells in the worksheet. Now, I need to adapt this functionality so that it can retrieve images which are stored as Place in cell in the excel .I want use this Azure Function for Business Central integration here is the code using Openize.Cells; using System.IO; using DocumentFormat.OpenXml; class Program { static void Main(string[] args) { string filePath = "C:\\Users\\Raj.Kamal\\Downloads\\test.xlsx"; // The path to your workbook string outputDirectory = "C:\\Users\\Raj.Kamal\\Downloads"; // Load the workbook from the specified file path Workbook wb = new Workbook(filePath); // Select the first worksheet from the workbook var worksheet = wb.Worksheets[0]; // Extract images from the worksheet var images = worksheet.ExtractImages(); // Check if the output directory exists; if not, create it if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } // Loop through each extracted image foreach (var image in images) { // Construct a unique file path for the image using a GUID var outputFilePath = Path.Combine(outputDirectory, $"Image_{Guid.NewGuid()}.{image.Extension}"); // Save the image data to the constructed file path using (var fileStream = File.Create(outputFilePath)) { image.Data.CopyTo(fileStream); } } } } Any code snippets, documentation links, or best practices would be greatly appreciated. Excel file:355Views1like0CommentsBurke Learns Blazor - Let's build the API!
This summer, Burke and Jon are porting theurlist.com to Blazor - a real world JavaScript application written in Vue.js. Join them each week as they use Visual Studio, Visual Studio Code and GitHub Copilot to rebuild this app and try to tackle every frontend issue you might encounter along the way. Now that we've got a working Blazor Static Web App with GitHub CI / CD and Azure deployment figured out, it's time to get that API going. Plus, Burke reveals how he conquered his fear of clowns. Community Links: https://www.theurlist.com/burke-learns-blazor Featuring: Jon Galloway (@jongalloway), Burke Holland (@burkeholland) #Beginner #Blazor #Web468Views1like0Comments