0

I'm using ClosedXML to create an sheet for excel and inserting data in it.

My code for this -

        FileStream fs = new FileStream("C:\\Images\\jcilogo.png", FileMode.Open);
        byte[] buffer = new byte[fs.Length];
        fs.Read(buffer, 0, buffer.Length);

        MemoryStream image = new MemoryStream(buffer);
        fs.Close();
        
        XLPicture pic = new XLPicture
        {
            NoChangeAspect = true,
            NoMove = true,
            NoResize = true,
            ImageStream = image,
            Name = "stamp"
        };

        XLMarker fMark1 = new XLMarker
        {
            ColumnId = 1,
            RowId = 1
        };

        XLMarker fMark2 = new XLMarker
        {
            ColumnId = 6,
            RowId = 6,
        };

        pic.AddMarker(fMark1);
        pic.AddMarker(fMark2);

        worksheet.AddPicture(pic);          
       

        worksheet.Cell("G25").Value = "ジョンソンコントロールズ株式会社";
        worksheet.Cell("H26").Value = "ンコントロー";
        worksheet.Cell("L26").Value = "ズ株式会";
        worksheet.Cell("H27").Value = "+99 998 77 65";
        worksheet.Cell("M28").Value = "ロールズ株式";
        worksheet.Cell("H28").Value = "ソンコントロールズ株";

This code is creating is creating an excel successfully but the image which i have used is coming above the text. like this -

enter image description here

But i want image to come under the text under the text which is present in teh cell or to have transparent background.

Something like this - enter image description here

Is it possible to make it transparent or to put it behind the text?

Community
  • 1
  • 1
omkar patade
  • 1,442
  • 9
  • 34
  • 66

1 Answers1

0

You are using a fork of the original ClosedXML library which adds image support.

Looking at the source code of that fork shows no methods or properties regarding transparency or positioning the image in front of or behind text (which would give the same result). So this is not possible without extending the library / this fork.

Raidri
  • 17,258
  • 9
  • 62
  • 65