Export to Sheet to XML

Posted by: cassius on 8 September 2017, 2:22 pm EST

  • Posted 8 September 2017, 2:22 pm EST

    Can someone help me with exporting  sheets to an xml file spread.net. I was able to export successfully in VB6 but having a bit of a problem in .net.
  • Replied 8 September 2017, 2:22 pm EST

    <div>In VB6 i used: </div><div> </div><div>    fpSpread1.Sheet = 1</div><div>    ret = fpSpread1.ExportRangeToXML(1, 2, 2, 10, "C:\Test\data\General Assumptions.xml", "root_element", "collection_element", ExportToXMLFormattedData, "")</div><div>   'Startup Cost</div><div>    fpSpread1.Sheet = 2</div><div>    ret = fpSpread1.ExportRangeToXML(1, 2, 5, 32, "C:\Test\data\Startup Cost.xml", "root_element", "collection_element", ExportToXMLFormattedData, "")</div><div>    'Fixed Assets Assumptions</div><div> </div><div>when convet to .net i use:</div><div> </div><div> FpSpread1.ActiveSheetIndex = 0</div><div>        ret = FpSpread1.ActiveSheet.SaveXml("C:\Users\cassius\Documents\Visual Studio 2008\Projects\Bizguide2010\Bizguide2010\Data\new data\General Assumptions.xml")</div><div>        'Startup Cost</div><div>        FpSpread1.ActiveSheetIndex = 1</div><div>        ret = FpSpread1.ActiveSheet.SaveXml("C:\Users\cassius\Documents\Visual Studio 2008\Projects\Bizguide2010\Bizguide2010\Data\new data\Sheet2.xml")</div><div>        </div><div>When i use the code below by itself it works well:</div><div>  FpSpread1.ActiveSheetIndex = 0</div><div>        ret = FpSpread1.ActiveSheet.SaveXml("C:\Users\cassius\Documents\Visual Studio 2008\Projects\Bizguide2010\Bizguide2010\Data\new data\General Assumptions.xml")</div><div> </div><div> however when i try to add another sheet to export it trows and error.</div><div>Can someone let me know what i am not doing. </div>
  • Replied 8 September 2017, 2:22 pm EST

    Hello,


    I used the same code as provided by you and it worked well for me and i am able to save the active sheets in XML format. Can you please tell us which error are you getting? Here is the code i used and it works well at my end:


    <BLOCKQUOTE>

         private void Form1_Load(object sender, EventArgs e)
            {
                fpSpread1.Sheets[0].Cells[0, 0].Text = "Sheet 1";
                fpSpread1.Sheets[1].Cells[0, 1].Text = "Sheet 2";
            }


            private void SaveToXML_Click(object sender, EventArgs e)
            {
                if (fpSpread1.ActiveSheetIndex == 0)
                    fpSpread1.ActiveSheet.SaveXml(@"D:\MyFolder\Sheet_1.xml");
                else if (fpSpread1.ActiveSheetIndex == 1)
                    fpSpread1.ActiveSheet.SaveXml(@"D:\MyFolder\Sheet_2.xml");
            }

    </BLOCKQUOTE>

    Please provide us with the steps to replicate the issue at our end. Thanks.

  • Replied 8 September 2017, 2:22 pm EST

    Hi <span class="Apple-style-span" style="font-family:Tahoma, Arial, Helvetica;font-size:12px;">Reeva,</span>

    Thanks for your help. The code was giving me a problem because I was not using the if/ elseif statement. The code is working fine now..Thanks a million!!!! 

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels