locked
Working with XML RRS feed

  • Question

  • User865178888 posted

    Hi,

    Iam working in the small enhancement of asp.net application. I have an xml file inbuilt with CSS and this creates an Excel file.  My requirement is to add new rows in the excel file. I have manually copy pasted the existing row and built the application, but nothing loads when i run the application.

    Any help will save me. Below is the xml iam using.

       <Row >
        <Cell ss:StyleID="s25"><Data ss:Type="String">{NAMECRITERIA}</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s38">
           <Data ss:Type="String">{WEIGHT}</Data>
         </Cell>
         <!--yoan-->
    
         <Cell ss:StyleID="s29"><Data ss:Type="String">Jan</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Feb</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Mar</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Apr</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">May</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Jun</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Jul</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Aug</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Sep</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Oct</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Nov</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">Dec</Data></Cell>
        <Cell ss:StyleID="s29"><Data ss:Type="String">TOT</Data></Cell>
       </Row>
       <Row>
        <Cell ss:StyleID="s26"><Data ss:Type="String">Target (monthly)</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s36">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C1}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C2}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C3}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C4}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C5}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C6}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C7}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C8}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C9}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C10}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C11}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{C12}</Data></Cell>
        <Cell ss:StyleID="s27"><Data ss:Type="Number">{CC12}</Data></Cell>
       </Row>
       <Row>
        <Cell ss:StyleID="s26"><Data ss:Type="String">Actual (monthly) - BRUT</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s36">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC1}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC2}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC3}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC4}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC5}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC6}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC7}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC8}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC9}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC10}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC11}</Data></Cell>
         <Cell ss:StyleID="s27"><Data ss:Type="Number">{AC12}</Data></Cell>
         <Cell ss:StyleID="s27" ss:Formula="=RC[-12]+RC[-11]+RC[-10]+RC[-9]+RC[-8]+RC[-7]+RC[-6]+RC[-5]+RC[-4]+RC[-3]+RC[-2]+RC[-1]"><Data ss:Type="Number"></Data></Cell>
       </Row>
    
    <Row>
      <Cell ss:StyleID="s26" ><Data ss:Type="String">% (monthly)</Data></Cell>
      <!--yoan-->
      <Cell ss:StyleID="s36">
        <Data ss:Type="String"></Data>
      </Cell>
      <!--yoan-->
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC1}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC2}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC3}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC4}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC5}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC6}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC7}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC8}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC9}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC10}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC11}</Data></Cell>
      <Cell ss:StyleID="s28" ><Data ss:Type="Number">{BC12}</Data></Cell>
      <Cell ss:StyleID="s28" ss:Formula="=(R[-1]C/R[-2]C)*100"><Data ss:Type="Number"></Data></Cell>
    </Row>
    
       <Row>
        <Cell ss:StyleID="s26" ><Data ss:Type="String">Target (YTD)</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s36">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC1}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC2}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC3}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC4}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC5}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC6}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC7}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC8}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC9}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC10}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC11}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC12}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{CC12}</Data></Cell>
       </Row>
    
       <Row>
        <Cell ss:StyleID="s26"><Data ss:Type="String">Actual (YTD) - NET pour Paye</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s36">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC1}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC2}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC3}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC4}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC5}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC6}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC7}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC8}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC9}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC10}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC11}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{DC12}</Data></Cell>
         <Cell ss:StyleID="s27" ss:Formula="=(R[-3]C)"><Data ss:Type="Number"></Data></Cell>
       </Row>
    
       <Row>
        <Cell ss:StyleID="s26"><Data ss:Type="String">% (YTD)</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s36">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC1}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC2}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC3}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC4}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC5}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC6}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC7}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC8}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC9}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC10}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC11}</Data></Cell>
        <Cell ss:StyleID="s28" ><Data ss:Type="Number">{EC12}</Data></Cell>
        <Cell ss:StyleID="s28" ss:Formula="=(R[-1]C/R[-2]C)*100"><Data ss:Type="Number"></Data></Cell>
       </Row>
    
       <Row>
        <Cell ss:StyleID="s26"><Data ss:Type="String">Diff (YTD)</Data></Cell>
         <!--yoan-->
         <Cell ss:StyleID="s37">
           <Data ss:Type="String"></Data>
         </Cell>
         <!--yoan-->
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC1}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC2}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC3}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC4}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC5}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC6}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC7}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC8}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC9}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC10}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC11}</Data></Cell>
        <Cell ss:StyleID="s27" ><Data ss:Type="Number">{FC12}</Data></Cell>
        <Cell ss:StyleID="s27" ss:Formula="=(R[-2]C) - (R[-3]C)"><Data ss:Type="Number"></Data></Cell>
       </Row>

    Thursday, September 11, 2014 11:13 PM

Answers

  • User61956409 posted

    Hi kriprka,

    Thanks for your post.

    I have an xml file inbuilt with CSS and this creates an Excel file.  My requirement is to add new rows in the excel file.

    Firstly, I’d like to know whether you get the data from this xml file to create an Excel file.If that is the case, you could add new row to the xml file then get data from this xml file to create the excel file. You could refer to the following code to add record to XML.

                XDocument doc = XDocument.Load(Server.MapPath("Source.XML"));
                XElement customer = new XElement("customer",
                    new XAttribute("customername", "Allen LEE"),
                    new XElement("firstn", "Allen"),
                    new XElement("lastn", "LEE"));
                doc.Root.Add(customer);
                doc.Save(Server.MapPath("Source.XML"));

    I have manually copy pasted the existing row and built the application, but nothing loads when i run the application.

    Secondly, could you explain more about it. it will help us to understand your problem.

    If you have any question about my reply, please post back freely.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 15, 2014 6:21 AM

All replies

  • User61956409 posted

    Hi kriprka,

    Thanks for your post.

    I have an xml file inbuilt with CSS and this creates an Excel file.  My requirement is to add new rows in the excel file.

    Firstly, I’d like to know whether you get the data from this xml file to create an Excel file.If that is the case, you could add new row to the xml file then get data from this xml file to create the excel file. You could refer to the following code to add record to XML.

                XDocument doc = XDocument.Load(Server.MapPath("Source.XML"));
                XElement customer = new XElement("customer",
                    new XAttribute("customername", "Allen LEE"),
                    new XElement("firstn", "Allen"),
                    new XElement("lastn", "LEE"));
                doc.Root.Add(customer);
                doc.Save(Server.MapPath("Source.XML"));

    I have manually copy pasted the existing row and built the application, but nothing loads when i run the application.

    Secondly, could you explain more about it. it will help us to understand your problem.

    If you have any question about my reply, please post back freely.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 15, 2014 6:21 AM
  • User865178888 posted

    Hello Fai,

    Below is the function which which calls PS_COL_CRITERIAS_BY_TARGETS_IS stored procedure and there is a function  Genere_Result inside the for where excatly this XML is called to create the excel.

    Public Function AjouteCriterias(ByVal valBonusPlan As Integer, ByVal valUPIN As String) As String

    Dim str_Retour As String

    str_Retour = ""

    Dim ds2 As Data.DataSet = SqlDataTrace.ExecuteDataset(ConfigurationManager.ConnectionStrings("SQLCS").ConnectionString, "PS_COL_CRITERIAS_BY_TARGETS_IS", valBonusPlan, valUPIN)

    Dim a As Integer

    Do While a < ds2.Tables(0).Rows.Count

    str_Retour = str_Retour & New Criteria_Affiche_Cls(valUPIN, valBonusPlan, ds2.Tables(0).Rows(a)("id_criteria"), _pathChemin).Genere_Result

    a = a + 1
    Loop

    Return str_Retour

    End Function

    Public Function Genere_Result() As String

    Dim str, str_Dash_Board As String

    str = ""

    str_Dash_Board = ChargeFile("Payrol_dash_board_corp.xml")

    '{NAMECRITERIA}
    str = chargedonnees(_id_criteria, str_Dash_Board)

    Return str

    End Function

    Please let me know if you need some more information.

    Thanks,

    Krishna.

    Wednesday, September 17, 2014 10:38 AM