White border around 'SheetToImage' image

Hi,

I used the following code to produce a image of one cell (although the issue is present with larger images):

Dim mysheet As Worksheet = m_appExcel.Worksheets("Customer Responses")
mysheet.PageSetup.PrintArea = "C7:C7"
mysheet.SheetToImage("O:\Projects\Test\myimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

I've attached the resulting image.

Is there any way to remove the white space that acts as a border around the actual cell image?

Cheers,

Steve

Hi Steve,

Well, I think you may add some lines of code to your code (as given below), it will work fine for your requirements.

e.g..,

Dim mysheet As Worksheet = m_appExcel.Worksheets("Customer Responses")
mysheet.PageSetup.PrintArea = "C7:C7"
mysheet.PageSetup.LeftMargin = 0
mysheet.PageSetup.RightMargin = 0
mysheet.PageSetup.BottomMargin = 0
mysheet.PageSetup.TopMargin = 0
mysheet.SheetToImage("O:\Projects\Test\myimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

Thank you.

Great, just what I needed!

Thanks,

Steve