SoFunction
Updated on 2025-03-01

C# deletes the image instance code in Excel

DLL file acquisition and reference

Method 1: Download the dll file package through the official website and unzip it. After decompressing the file, refer to the file in the bin folder to the C# program.

Method 2: Get the dll through the Nuget website.

using ;



namespace RemoveImg

{

  class Program

  {

    static void Main(string[] args)

    {

      //Load Excel document
      Workbook workbook = new Workbook();

      ("");



      //Get the first worksheet
      Worksheet sheet = [0];



      //Get the first picture in the worksheet
      ExcelPicture picture = [0];



      //Delete the picture
      ();



      //Save the document
      ("Delete picture.xlsx", ExcelVersion.Version2013);



    }

  }

}

After running the program, the specified image will be deleted.

Extended Learning:

Delete mini images

Free supports deleting specified minimaps from minimaps groups, and also supports deleting the entire minimaps from the worksheet.

//Create a Workbook instanceWorkbook workbook = new Workbook();
//Load Excel document("Add minimap.xlsx");
 
//Get the first worksheetWorksheet sheet = [0];
 
//Get the first mini image groupISparklineGroup sparklineGroup =[0];
 
////Delete the first mini image in the picture group//ISparklines sparklines =sparklineGroup[0];
//(sparklines[0]);
 
//Delete the first mini-picture group from the worksheet(sparklineGroup);
   
//Save the document("Delete mini image.xlsx",ExcelVersion.Version2010);