Welcome to OpenXML Developer Sign in | Join | Help

How to write the values(number/string) in the defined cells using OPENXMLformat SDK

Last post 09-01-2008, 2:16 AM by vikassony. 4 replies.
Sort Posts: Previous Next
  •  08-25-2008, 7:17 AM 3602

    How to write the values(number/string) in the defined cells using OPENXMLformat SDK

    HI ,

    I am Playing with OpenXML.

    I have an issue to write the strings in cells.

    name of the cell has been defined by the user.

    here 2 problem i am facing

    1.After writting any string to the cell, i am able to write the strings in cell comfortably but when i am trying to open the saved XLSM file it says that "converter failed to open the file."

    2.how i can write the values(number/string) in the cells for that name has been defined by user.

    Another issue is how to delete a sheet using OPEN XML API if the sheet is keeping the relationship with other sheets.

    i am able to delete the sheet if that sheet is not having any relationship.

    Any help or tips is greatly appreciated.

    Regards

    Vikas

  •  08-25-2008, 8:09 PM 3606 in reply to 3602

    Re: How to write the values(number/string) in the defined cells using OPENXMLformat SDK

    Answer for 2. how i can write the values(number/string) in the cells for that name has been defined by user.

    The answer would vary based on if you wish to write a number or string.

    For number, you can just go ahead and modify the <v> element value corresponding to the named cell/range.

    For string:

    1. If you want to change the cell value at all places that a particular string appears, you can modify the sharedStrings.xml corresponding to the index mentioned in the <v> element corresponding to the cell.

    2. If you wish to modify just one particular cell value, then you can make use of inline strings (<is> and <t> elements).

    To get to the cell defined as a named range by the users, you can look at the <definedNames> in the workbook.xml

  •  08-26-2008, 6:54 AM 3608 in reply to 3606

    Re: How to write the values(number/string) in the defined cells using OPENXMLformat SDK

    hi

    i'm new to this forum abd i have seen your post. i hope you can help me.

    here is the problem:
    i want to fill data into sheet(into excel document) from an array
    i fill up an array and create the sheet in the package. i create also some other files(like workbook.xml, theme.. and i create relationship between workbook and sheet) i have manually created the sharedstrings.xml and put data in it. but there is no way it will open. the sheet has data in it and the sharedstrings.xml is filled with data that is actually on the sheet. it gives an error "Excel can not open the file because the file format or file extension is not valid"
    i generate the XML files with visual studio(VB).

    i have also tried to use an existing excel file, but it deletes all the files in it. i think it's because i cant have an filemode.append attribute in the package.open (it says it's not supported?)

    if you have any example of it, or any other help, it would be great

    thanks, zh.

    (if possible, send it to my mail: mojesmeti2@gmail.com)
  •  08-26-2008, 7:33 PM 3612 in reply to 3602

    Re: How to write the values(number/string) in the defined cells using OPENXMLformat SDK

    Hello Vikas,

    I am not sure about your question "how to delete a sheet using OPEN XML API if the sheet is keeping the relationship with other sheets".Do you mean to say that when you delete the sheet, the workbook doesnt open?

    BTW here is a link which provides information as how to delete a worksheet

    http://msdn.microsoft.com/en-us/library/bb739834.aspx

    Ankush

     

     

     

  •  09-01-2008, 2:16 AM 3625 in reply to 3612

    Re: How to write the values(number/string) in the defined cells using OPENXMLformat SDK

    thanks.

    I had a look on the msdn snippet but this works only for very flat sheet which contains only texcts in the cell.NO formula, no reference, no defined names, no macro......

     

    Vikas

View as RSS news feed in XML