posts - 2,comments - 1,trackbacks - 0

'第一步引用命令空间[这步最重要的]

Imports <xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition">

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        '加载RDLC文件[记得引用命名空间]。

        Dim feedXML As XDocument = XDocument.Load("D:\HjSoft\R01单.rdlc")

        '循环访问节点。

        For Each result In feedXML.<Report>.<Body>.<ReportItems>.<Textbox>

            '判断节点的属性。

            If result.@Name = "textbox3" Then

                '节点下的节点。

                Dim B = result.<Value>

                '修改值

                B.Value = Now.ToString

            End If

        Next

        '保存修改后的记录。

        feedXML.Save("D:\HjSoft\R01单.rdlc")

    End Sub

=====================================

搞了一天才知道怎么一回事,希望对其它人有所帮助。

=====================================

付上XML文件内容。

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

 <InteractiveHeight>29.7cm</InteractiveHeight>

 <rd:DrawGrid>true</rd:DrawGrid>

 <InteractiveWidth>21cm</InteractiveWidth>

 <rd:GridSpacing>0.25cm</rd:GridSpacing>

 <rd:SnapToGrid>true</rd:SnapToGrid>

 <rd:ReportID>8f248b67-8dd9-4553-9946-ab6210b7a7d6</rd:ReportID>

 <PageWidth>21.72cm</PageWidth>

 <Code/>

 <Width>21.6cm</Width>

 <Body>

   <ColumnSpacing>1cm</ColumnSpacing>

   <ReportItems>

     <Textbox Name="textbox3">

       <rd:DefaultName>textbox3</rd:DefaultName>

       <Visibility>

         <Hidden>true</Hidden>

       </Visibility>

       <Top>3cm</Top>

       <Width>9.75cm</Width>

       <Style>

         <FontFamily>宋体</FontFamily>

         <PaddingLeft>2pt</PaddingLeft>

         <PaddingRight>2pt</PaddingRight>

         <PaddingTop>2pt</PaddingTop>

         <PaddingBottom>2pt</PaddingBottom>

       </Style>

       <ZIndex>2</ZIndex>

       <CanGrow>true</CanGrow>

       <Left>0.25cm</Left>

       <Height>0.63492cm</Height>

       <Value>2008.07.17 18:06:25</Value>

     </Textbox>

     <Textbox Name="textbox2">

       <rd:DefaultName>textbox2</rd:DefaultName>

       <Top>1.5cm</Top>

       <Width>9.75cm</Width>

       <Style>

         <FontFamily>宋体</FontFamily>

         <PaddingLeft>2pt</PaddingLeft>

         <PaddingRight>2pt</PaddingRight>

         <PaddingTop>2pt</PaddingTop>

         <PaddingBottom>2pt</PaddingBottom>

       </Style>

       <ZIndex>1</ZIndex>

       <CanGrow>true</CanGrow>

       <Left>0.25cm</Left>

       <Height>1.25cm</Height>

       <Value>文本框2的第一行内容。</Value>

     </Textbox>

     <Textbox Name="textbox1">

       <rd:DefaultName>textbox1</rd:DefaultName>

       <Top>0.5cm</Top>

       <Width>9.75cm</Width>

       <Style>

         <FontFamily>宋体</FontFamily>

         <PaddingLeft>2pt</PaddingLeft>

         <PaddingRight>2pt</PaddingRight>

         <PaddingTop>2pt</PaddingTop>

         <PaddingBottom>2pt</PaddingBottom>

       </Style>

       <CanGrow>true</CanGrow>

       <Left>0.25cm</Left>

       <Height>0.63492cm</Height>

       <Value>文本框1的文本内容。</Value>

     </Textbox>

   </ReportItems>

   <Height>13.9cm</Height>

 </Body>

 <Language>zh-CN</Language>

 <PageHeight>13.97cm</PageHeight>

</Report>

posted on 2008-07-18 15:31 逍遥海盗船 阅读(...) 评论(...) 编辑 收藏