Exporting to Excel and Printing

4 posts, 0 answers
  1. Rajnikant Rajwadi
    Rajnikant Rajwadi avatar
    15 posts
    Member since:
    Sep 2009

    Posted 27 Oct 2009 Link to this post

    Hello To All,

    I write code for export grid data to excel and print.
    Its working fine on my local computer. when i upload source code on server its not working at all.

    Please help me. What to do ?

    Thanks,
    Rajnikant
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 27 Oct 2009 Link to this post

    Hi Rajnikant,

    Most probably the application does not have enough rights to save the file on the server. You can try local export/print similar to our latest demos:

    http://demos.telerik.com/silverlight/beta/#GridView/Exporting (Save as file directly)
    http://demos.telerik.com/silverlight/beta/#GridView/Printing (PrintToHtml() method)

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Sarper
    Sarper avatar
    22 posts
    Member since:
    Aug 2012

    Posted 09 Aug 2012 Link to this post

    Hello,

    I wanted to use your gridview's print feature. but the link you give does not work.
    http://demos.telerik.com/silverlight/beta/#GridView/Printing (PrintToHtml() method)

    Your new printing link has some problems; it only works for first time. ( PrintAndExportWithRadDcument )
    In first time,
    Printing page opens and shows me a dialog. If I click cancel, it closes that dialog successfully.
    After, the second time; Print button does not work. Does nothing.

    Can you help me to find out what is the problem?
    Thank you,
    Sarper

  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2012 Link to this post

    Hello Sarper,

     We've fixed this issue immediately and the fix will be part of our next demos upload. In the meantime here is how to fix it at your end:

    PrintAndExportWithRadDocumentModel.cs
    ...............................................................................
    public void Print(object parameter)
    {
        RadGridView grid = (RadGridView)parameter;

        RadRichTextBox rtb = null;
        string rtBname = "RadRichTextBox1";

        Grid parent = grid.ParentOfType<Grid>();
        if (parent != null)
        {
            if (parent.FindName(rtBname) == null)
            {
                rtb = new RadRichTextBox() { Height = 0 };
                rtb.Name = rtBname;
                parent.Children.Add(rtb);
                rtb.ApplyTemplate();
            }
            else
            {
                rtb = parent.FindName(rtBname) as RadRichTextBox;
            }
        }

        if (rtb != null)
        {
            rtb.Dispatcher.BeginInvoke((Action)(() =>
                {
                    rtb.Document = CreateDocument(grid);
                }));

            rtb.Print("MyDocument", Documents.UI.PrintMode.Native);
        }
    }

    I've added 1000 Telerik points to your account. 

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top