Exception while Exporting Datagridview data with Images to Excel...

Hi Everyone,
I have datagridview in that 17 columns are text columns and 5 columns are Image columns,when I'm trying to export whole gridview data's along with images to EXCEL,getting "HRESULT:
0x800A03EC" Error..While debugging the code I'm getting the error on image column not able to export..
Can anybody help us to resolve this issue..
Here is my code which i used:
private void btnexportexcel_Click(object sender, EventArgs e)
try
SaveFileDialog savefile = new SaveFileDialog();
savefile.Filter = "Excel (*.xls)|*.xls";
if (savefile.ShowDialog() == DialogResult.OK)
if (!savefile.FileName.Equals(string.Empty))
FileInfo finfo = new FileInfo(savefile.FileName);
if (finfo.Extension.Equals(".xls"))
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2) ;
int i = 0;
int j = 0;
for (i = 0; i <= dataGridView1.RowCount - 1; i++)
for (j = 0; j <= dataGridView1.ColumnCount - 1; j++)
DataGridViewCell cell = dataGridView1[j, i];
xlWorkSheet.Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
xlWorkSheet.Columns.AutoFit();
if (cell.Value.GetType() == typeof(Bitmap))
string image =Convert.ToString(dataGridView1.CurrentRow.Cells[i].Value); 
Excel.Range oRange = (Excel.Range)xlWorkSheet.Cells[i + 1, j + 1];
float Left = (float)((double)oRange.Left);
float Top = (float)((double)oRange.Top);
const float ImageSize = 32;
xlWorkSheet.Shapes.AddPicture(image, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, Left, Top, ImageSize, ImageSize);
oRange.RowHeight = ImageSize + 2; 
else
xlWorkSheet.Cells[i + 1, j + 1] = cell.Value;
xlWorkBook.SaveAs(savefile.FileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
MessageBox.Show("Excel file created , you can find the file " + savefile.FileName);
else
MessageBox.Show("Invalid file type");
else
MessageBox.Show("You did pick a location " + "to save file to");
catch (Exception ex)
MessageBox.Show("Exception Occured", ex.Message);
Thanks & Regards RAJENDRAN M

Hi Everyone,
I have datagridview in that 17 columns are text columns and 5 columns are Image columns,when I'm trying to export whole gridview data's along with images to EXCEL,getting "HRESULT:
0x800A03EC" Error..While debugging the code I'm getting the error on image column not able to export..
Can anybody help us to resolve this issue..
Here is my code which i used:
private void btnexportexcel_Click(object sender, EventArgs e)
try
SaveFileDialog savefile = new SaveFileDialog();
savefile.Filter = "Excel (*.xls)|*.xls";
if (savefile.ShowDialog() == DialogResult.OK)
if (!savefile.FileName.Equals(string.Empty))
FileInfo finfo = new FileInfo(savefile.FileName);
if (finfo.Extension.Equals(".xls"))
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2) ;
int i = 0;
int j = 0;
for (i = 0; i <= dataGridView1.RowCount - 1; i++)
for (j = 0; j <= dataGridView1.ColumnCount - 1; j++)
DataGridViewCell cell = dataGridView1[j, i];
xlWorkSheet.Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
xlWorkSheet.Columns.AutoFit();
if (cell.Value.GetType() == typeof(Bitmap))
string image =Convert.ToString(dataGridView1.CurrentRow.Cells[i].Value); 
Excel.Range oRange = (Excel.Range)xlWorkSheet.Cells[i + 1, j + 1];
float Left = (float)((double)oRange.Left);
float Top = (float)((double)oRange.Top);
const float ImageSize = 32;
xlWorkSheet.Shapes.AddPicture(image, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, Left, Top, ImageSize, ImageSize);
oRange.RowHeight = ImageSize + 2; 
else
xlWorkSheet.Cells[i + 1, j + 1] = cell.Value;
xlWorkBook.SaveAs(savefile.FileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
MessageBox.Show("Excel file created , you can find the file " + savefile.FileName);
else
MessageBox.Show("Invalid file type");
else
MessageBox.Show("You did pick a location " + "to save file to");
catch (Exception ex)
MessageBox.Show("Exception Occured", ex.Message);
Thanks & Regards RAJENDRAN M

Similar Messages

  • Error "Encountered an error while exporting the data. View the lof file (DPR-10126)

    Hello,
    I would like to have sugestions and help to solve a problem in IS 4.2.
    I've created a view from two tables, joined together with the key from each one.
    Then i've binded the rule with the view (mentioned above) created and calculated score for it.
    The calculation is successful, however when i try to export all failed data i have the following error:
    "Encountered an error while exporting the data. View the lof file (DPR-10126)"
    When exporting failed data from calculations made directly to the datasources i do not encounter any problem, but when i try to export all data to CSV file (not only the 500 results limit) i have this kind of error.
    However, when i visualize the data from the view created, it is also possible to export to csv file.
    Resuming, the error occurs only when exporting all failed data from the view.
    Can anyone help with this issue?
    Thx
    Best Regards,

    Hello,
    Your information is correct.
    I've just confirmed it in the 4.2 SP3 Release Notes and they specifically refer to this issue.
    A user who has 'View objects' rights for the project and a failed rule connection cannot export the failed data. This issue has been fixed in this release.
    Thank you very much for your input.
    Best Regards,

  • Problem while exporting the data from a report to an excel file.

    Hi SAP guru's,
    I have a problem while exporting the data from a report to an excel file.
    The problem is that after exporting, the excel file seems to have some irrelevant characters....I am checking this using SOST transaction..
    Required text (Russian):
    Операции по счету                                    
    № документа     Тип документа     № учетной записи     Дата документа     Валюта     Сумма, вкл. НДС     Срок оплаты     Описание документа
    Current Text :
       ? 5 @ 0 F 8 8  ? >  A G 5 B C                                   
    !   4 > : C       "" 8 ?  4 > : C      !   C G 5 B = > 9  7 0 ? 8 A 8        0 B 0  4 > : C         0 ; N B 0      ! C <       ! @ > :  > ? ; 0 B K        ? 8 A 0 = 8 5  4 > : C
    Can you help me making configuration settings if any?
    Regards,
    Avinash Raju

    Hi Avinash
    To download  such characteres you need to adjust code page to be used during export. You can review SAP note 73606 to identify which code page is required for this language
    Best regards

  • How to export table data with coloring of cell according to value.

    Hi all,
    I am using jdeveloper 11.1.1.6
    i want to export table data with lot of formatting. like with coloring of cell according to value and so many.How to do that?

    Hi,
    like with coloring of cell according to value and so many.How to do that?
    Answer is, you can't
    Frank

  • How to export the data from table to excel sheet

    hi experts i have some problem am trying to export the data fro table to Excel sheet  in the view controller i have created one button wit public void onActionCLEAR(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCLEAR(ServerEvent)
       //wdContext.nodeBapi_Salesorder_Getlist_Input().
       //wdContext.nodeBapi_Salesorder_Getlist_Input().invalidate();
        //@@end
      //@@begin javadoc:onActionExporToExcel(ServerEvent)
      /** Declared validating event handler. */
      //@@end
      public void onActionExporToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionExporToExcel(ServerEvent)
         try{
         FileOutputStream fos=new FileOutputStream("Test.xls");
          PrintStream ps=new PrintStream(fos);
          ps.println("<html><body><table border=1>");
          int size=wdContext.nodeBapi_Salesorder_Getlist_Input().size();
           Iterator attributes=wdContext.getNodeInfo().iterateAttributes();
           ps.println("<tr>");
           while(attributes.hasNext()){
            ps.println("<th>");
            DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
            ps.println(attrName.getName());
            ps.println("</th>");
           ps.println("</tr>");
          for(int i=0; i<wdContext.nodeBapi_Salesorder_Getlist_Input().size();i++)
            attributes=wdContext.getNodeInfo().iterateAttributes();
            ps.println("<tr>");
            IWDNodeElement ele=wdContext.getElementAt(i);
            while(attributes.hasNext()){
              ps.println("<td>");
              DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
              ps.println(""+ele.getAttributeAsText(attrName.getName()));
              ps.println("</td>");
            ps.println("</tr>");
           ps.println("</table></body></html>");
           ps.flush();
           ps.close();
           fos.close();
          catch(Exception e){
           wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
          finally{
         //return("Test.xls")  ;
        //@@end
      }h action and i have return the code
    its running sucessfully but am not able to perform the action plz help me

    Hi,
    You shouldn't use DataAttributeInfo as it is an internal object, if I'm correct.
    Use IWDAttributeInfo instead of DataAttributeInfo and it should work
    (See also API doc of IWDNodeInfo.iterateAttributes() at http://help.sap.com/javadocs/nwce/ce711sp02/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDNodeInfo.html#iterateAttributes())
    Cheers,
    Robin

  • Can you export the date and user to Excel that appears into a Comments field in a tracking list?

    Hi everyone,
    Can you export the date and user to Excel that appears into a Comments field in a tracking list?
    When i export a tracking list with a Comment field in the Content type, the screen where you enter the data for an item, the Comments field just export the text of the comment into the Excel file.
    In the Comments field appears also, besides the comment text,  the user and date from who and when the comment is added.
    Is there a way to export also the user and the date?
    Thanks
    Wim

    create another comment field that doesn't use 'appending', and through SP Designer change workflow keep
    updating that field with the new comments  (prepend the field with date/username/new comment). Hide the field on all forms, but put it in the view you need to export to Excel.
    Please refer few more links: Hope they will help
    http://www.nothingbutsharepoint.com/2009/04/16/versioning-append-changes-to-existing-text-view-entries-aspx/
    http://sympmarc.com/2011/02/07/showing-all-versions-of-append-changes-to-existing-text-in-a-data-view-web-part-dvwp/comment-page-3/
    https://mossipqueen.wordpress.com/2013/03/06/display-all-appending-field-entries-in-a-single-list-view/
    http://community.office365.com/en-us/f/154/t/278560.aspx
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Problem while exporting to PDF with japanese character in Crystal Report X1

    Hi,
    I am using Crystal report X1 with classic ASP on a Windows 2003 Enterprise Server, SP 2. In my application, I have to export the report into PDF, CSV, DOC formats. I am have Japanese strings in the report. While exporting to PDF, empty boxes has displayed in the place of Japanese string and in CSV file, question mark has been displayed instead of Japanese string. But the Doc file is exported correctly. I have not installed any language support software either in server or in client machine. I have used MS Gothic and Arial Unicode MS fonts for the text-objects which has Japanese strings.
    Please give me a solution so that I will get PDF file with Japanese strings instead of empty box or question mark.
    Do I need to install any language support pack software?
    Thanks in advance.
    Regards,
    Manju

    Hi Don,
    Thank You for your reply. I have resolved the issue of exporting to pdf from crystal report X1 having Japanese data after installing the language pack.
    But when I am exporting to CSV or TXT, i am getting ??? instead of Japanese characters. I have tried "export" through crystal report designer and got ??? instead of Japanese.
    The Crystal report version I am using is Crystal report X1  11.0.0.1282
    Crystal Report Desinger is installed in Windows Xp machine
    Font set for Text object is Arial Unicode MS, MS PMincho, MS PGothic
    Does the Crystal report X1 11.0.0.1282 has the UTF-8 support for CVS / txt
    Please provide me a solution
    Thanks in advance,
    Regards,
    Manju

  • While Export the data to MS Word - How to avoid the Frames ???

    Hi All,
    I export the data from Crystal Report XI to Word document (doc) file , i used Text objects in the Report , in document file it's converted to  Frames and overlapped with other frames(so some data are hidden). is it possible to avoid the frames while exporting the report to word document.
    Thanks in advance.
    J.Baski

    Hello,
    It would be better if you format your report so your objects do not overlap but I realize sometimes it can't be avoided.
    Other option is to upgrade to CR XI R2 and test again, it is a free upgrade.
    Go to this link: http://www.sdn.sap.com/irj/boc and download the trial version of CR XI R2 and use your XI keycode, then apply the patches which you can get to by clicking on the BusinessObjects tab above, then Downloads.
    Direct link to the Trial version: http://www.sap.com/solutions/sapbusinessobjects/sme/freetrials/index.epx
    Other option is to export to Word Editable may be a solution for you also.
    Thank you
    Don

  • How to Display RTF data with images from SQL database in Crystal Report

    I am using Crystal report in my WPF application, I have generate Question Paper Report, in which have Question with images. Question with images are stored in SQL Server in rtf format, I want to generate Question report with RTF Text and Images in report

    Hello Sir,
    I am still Facing problem in Crystal report generation with RTF Data (Text + Images),
    I am storing Questions in SQL Server which are RTF Format, Questions have Text + Images..
    I changed field data type then also i didn't get image in Crystal report
    if i browse an image n stored that in DB then its displaying in Crystal report, but when i pasted that image in RichTextBox and saved that in DB then no data displayed in Crystal report.
    My Table Structure is
    Table Name: tblQuestions
    field :    Questions Varbinary(max)
    I tried with nvarchar(max) also but its aslo not working

  • Unhandled Exception- While Exporting Universe

    Hi ,
    While exporting Universe into CMS , we have got Unhandled Exception: Access_Violation_Exception.
    We are not able to export any universe into CMS.

    Does your account have enough rights to export to CMS?
    Are you able to import the current version of universe on the CMS successfully?
    Edited by: ramaks on Dec 1, 2009 8:21 PM

  • Export my data with windows safe mode

    i have problems with windows server 2003 st that i can open windows in safe mode only ,
    i want to export my data in that case !!!
    Any Help ...

    That's a Windows, not an Oracle problem. Safe mode is only suitable for OS maintenance tasks, not for regular working. Many services don't run, dlls are not loaded. Solve your basic problem, then start Oracle again.
    Werner

  • Export Users data with group membership

    Hey Guys,
    I'm using csvde to export users data for management reports.
    I'm asked to add to the exported data the group membership of the users and I'm having problem doing that.
    My current script is:
    csvde.exe -s 192.168.xx.xx -d "ou=CS,dc=Domain,dc=com" -r objectClass=user -l "Company,DisplayName,sAMAccountName,title,lastlogon,pwdLastSet" -f c:\usersonly-Users.csv
    Can anyone help me adding column with groups the user is member of?
    Thanks
    Nir 

    Add the memberOf attribute to the list of attribute values to retrieve.
    Richard Mueller - MVP Directory Services

  • Export Topology Data with an API

    I want to export Topology Data stored in Oracle to GML 3 or another specific data format.
    I want to do this with an API? Is this possible and does it make sence to do this with an API? Is there an other way to do this? (The export2gml fuction in Oracle 10g does not provide an export von topoloy elements)

    You could certainly use export2gml to export the nodes and edges from the topology model (via their respective tables). Once you have the GML representations of these just about any other topology model that can read GML should know what to do with these. What exactly are you looking for that you are not finding?
    -Justin

  • Export the data with Alias from the alternative table using ODI

    Hi!
    How to export the data from Essbase with Alias from the alternative table using ODI?
    Thanks.

    Are you on 10.1.3.6.x? Then: http://john-goodwin.blogspot.com/2008/09/odi-series-part-2-agent.html
    Are you on 11g? Then: http://john-goodwin.blogspot.com/2010/12/managing-odi-11g-standalone-agents.html
    I will say with only a mild amount of shame and a large amount of gratitude that I installed both releases' agents through John's blog posts.
    Regards,
    Cameron Lackpour
    Edited by: CL on Jun 4, 2012 5:48 PM
    Whoops, had the same link in there twice.

  • How to export the data as integer into excel sheet?

    Hi All,
         I am working on export to excel functionality and using JEXCEL API to create it.  When I export the data to excel sheet, the data are stored in text format in the excel sheet.  If I click on summation button on excel sheet,  it is not summing up the column values since it is stored as the text format. 
    I am writing the following code:
    for(Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();){
    String attributeName = (String)iter.next();
    for(int index = 0; index < dataNode.size(); index++){
    try{
    IWDNodeElement nodeElement = dataNode.getElementAt(index);
    String colVal = nodeElement.getAttributeAsTex(attributeName);
    Label value = new Label(j, index + 1, colVal);
    sheet.addCell(value);
    j++;
    Here colVal is the variable which holds the data in string format.  So I was just trying to convert it into integer format and used Integer.parseInt(colVal).
    But Label keyword accepts only the int,int,string arguments. 
    Is there any other option to change it as integer value while exporting to excel sheet.
    Pls suggest.
    This is very urgent.
    Regards,
    Subashini.

    Hi Gopal,
    Pls refer the following link.
    /people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
    I have used the same coding which is mentioned in this link. 
    And also I cannot use integer.parseInt(colval)  because new Label()  will accept only the int,int,string as parameters. 
    Here goes my to excel method code which exports the data to excel sheet .
    private FileInputStream toExcel(IWDNode dataNode, Map columnInfos) {
    String fileName = "output.xls";
    IWDCachedWebResource cachedExcelResource = null;
    int i = 0;
    try{
    File f = new File("output.xls");
    WritableWorkbook workbook = Workbook.createWorkbook(f);
    WritableSheet sheet = workbook.createSheet("First Sheet", 0);
    for(Iterator coluinfoitr = columnInfos.keySet().iterator(); coluinfoitr.hasNext();){
    Label label = new Label(i, 0, (String)columnInfos.get(coluinfoitr.next()));
    sheet.addCell(label);
    i++;
    int j = 0;
    for(Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();){
    String attributeName = (String)iter.next();
    for(int index = 0; index < dataNode.size(); index++){
    try{
    IWDNodeElement nodeElement = dataNode.getElementAt(index);
    String colVal = nodeElement.getAttributeAsText(attributeName);
    Label value = new Label(j, index + 1, colVal);
    sheet.addCell(value);
    catch (Exception e){
    wdComponentAPI.getMessageManager().reportException(" Data Retrive Err :" + e.getLocalizedMessage(),false);
    j++;
    workbook.write();
    FileInputStream excelCSVFile = new FileInputStream(f);
    cachedExcelResource = getCachedWebResource(excelCSVFile, fileName, WDWebResourceType.getWebResourceType("xls", "application/ms-excel"));
    wdContext.currentContextElement().setExcelDownload(cachedExcelResource.getURL());
    workbook.close();
    It is exporting the data in text format.  So I am unable to sum up the column values in the excel sheet.
    I need an alternate solution wherein I can export the data in integer format to excel sheet and then sum up the column values by clicking on summation button.
    Hope I am clear now.
    Pls suggest.
    Regards,
    Subashini.

Maybe you are looking for

  • What are the Cleansing steps we can perform outside the DMU tool?

    We need your advise on this According to DMU documentation, There are three possible reasons for a value to have invalid binary representation in the database and their respective fixes using DMU tool a) An application stores binary values, Fix: To c

  • How to setup acknowledgements? Please help!

    Hi Experts,    I have following scenario.    IDOC--> XI----> BizTalk    In this scenario, IDOC is sent from SAP R/3 system to XI. XI then sends it to BizTalk using JMS adapter.    Everything works fine and BizTalk also receives the IDOC message. But

  • Reboot fails after software update - what now?

    I've just performed a regular software update. I think it included the following 4 items: - iPhoto 08 (enhanced printing etc.) - Raw module update - 10.5.5 update - ??? don't remember this one Three of the updates required a reboot so I opted to rebo

  • Table for loans given to customer

    hi to all, i m new to abap, i have requirement for developing a report that list loans given to customer.im unable to find table for loans please help me out .its very very urgent.

  • GR process for TAS item category

    The issue is: We have issued lot of PO as drop shipment kind of scenario. ie. not relevant for GR. There are many sales order open PR lying with schedule line which is not valid for GR. We want to do the GR process for them. when i try to do a GR it