2013-04-09 2 views
0

작성한 Excel 파일에서 리소스의 이미지를 바닥 글로 사용하려면 어떻게해야합니까?리소스의 바닥 글이 Excel에서 바닥 글로 표시됩니다.

이 확실히 작동하지 않습니다

xlWorkSheet.PageSetup.CenterFooterPicture = Properties.Resources.stopka; 

이후 : 암시 적 형식을 변환 할 수 없습니다 'System.Drawing.Bitmap'이 작품

확인 Microsoft.Office.Interop.Excel.Graphic '로 :

xlWorkSheet.PageSetup.CenterFooterPicture.Filename = Application.StartupPath + "\\stopka.png"; 
    xlWorkSheet.PageSetup.CenterFooterPicture.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue; 
    xlWorkSheet.PageSetup.CenterFooterPicture.Width = 590; 
    xlWorkSheet.PageSetup.CenterFooter = "&G"; 

하지만 내가 필요한 것은 아닙니다. 응용 프로그램 폴더가 아닌 프로젝트 리소스에서 이미지를 얻고 싶습니다.

답변

0

이 작동 :

System.Reflection.Assembly CurrAssembly = System.Reflection.Assembly.LoadFrom(System.Windows.Forms.Application.ExecutablePath); 
    System.IO.Stream stream = CurrAssembly.GetManifestResourceStream("Oferty_BMGRP.Resources.stopka.png"); 
    string temp = Path.GetTempFileName(); 
    System.Drawing.Image.FromStream(stream).Save(temp); 


    xlWorkSheet.PageSetup.CenterFooterPicture.Filename = temp; //Application.StartupPath + "\\Resources\\stopka.png"; 
    xlWorkSheet.PageSetup.CenterFooterPicture.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue; 
    xlWorkSheet.PageSetup.CenterFooterPicture.Width = 590; 
    xlWorkSheet.PageSetup.CenterFooter = "&G"; 

이미지 "stopka.png"는 등의 임베디드 리소스를 설정했다.

0

마이크로 소프트가

MSDN의

CenterFooterPicture에서 사용할 수있는 문서입니다 다음 CenterFooterPicture 속성에 대한 설정 옵션을 제공하지 않기 때문에 - 바닥 글의 중앙 부분에 대한 그림을 나타내는 그래픽 오브젝트를 돌려줍니다. 그림에 대한 속성을 설정하는 데 사용됩니다.

Link to Refer

+0

여기에 표시된대로 : http://msdn.microsoft.com/en-us/library/office/ff195659.aspx 속성을 설정하고 ActiveSheet.PageSetup.LeftFooter = "&지". 하지만 여전히 특정 경로의 외부 파일을 사용할 수 있습니다. 나는 자원 파일을 사용할 수 있기를 희망했다. –

+0

해당 VBA에서 먼저 이미지 소스를 설정 한 다음 ActiveSheet.PageSetup.LeftFooter = "& G"를 설정합니다. 너도 똑같은거야? – Smaug

+0

예. 디스크에 저장된 파일에서 이미지를 설정하는 데는 아무런 문제가 없습니다. 하지만 임베디드 리소스 이미지를 사용하고 싶습니다. 예 나는 easly 작업을했지만, 거기에 리소스 파일을 사용할 수 없다. 적어도 어떻게해야할지 모르겠다. –

관련 문제