Telerik Web Report Designer Report From Xml

1 Answer 370 Views
Report Designer - Web Report Designer (standalone) Report Viewer - HTML5 Report Viewer - HTML5 WebForms
AYHAN
Top achievements
Rank 1
AYHAN asked on 21 Aug 2023, 08:38 AM

Hi,

I have report xml data previously produced with Telerik Windows Designer in my database. That is the xml version of the report.

For example:
<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Report Width=\"6.5in\" Name=\"test\" xmlns=\"http:// schemas.telerik.com/reporting/2021/1.0\">\r\n <Items>\r\n <PageHeaderSection Height=\"1in\" Name=\"pageHeaderSection1\">\r\n <Items>\ r\n <TextBox Width=\"1.2in\" Height=\"0.2in\" Left=\"2.7in\" Top=\"0.4in\" Value=\"test\" Name=\"textBox1\ " />\r\n </Items>\r\n </PageHeaderSection>\r\n <DetailSection Height=\"2in\" Name=\"detailSection1\" />\r\n <PageFooterSection Height=\ "1in\" Name=\"pageFooterSection1\" />\r\n </Items>\r\n <PageSettings PaperKind=\"Letter\" Landscape=\"False\" ColumnCount=\"1\" ColumnSpacing= \"0in\">\r\n <Margins>\r\n <MarginsU Left=\"1in\" Right=\"1in\" Top=\"1in\" Bottom=\"1in\" />\ r\n </Margins>\r\n </PageSettings>\r\n <StyleSheet>\r\n <StyleRule>\r\n <Style>\r\n <Padding Left=\"2pt\" Right =\"2pt\" />\r\n </Style>\r\n <Selectors>\r\n <TypeSelector Type=\"TextItemBase\" />\r\n <TypeSelector Type=\"HtmlTextBox\ " />\r\n </Selectors>\r\n </StyleRule>\r\n </StyleSheet>\r\n</Report>

I want to be able to design and send such xml content to web report designer.
Converting to json format, deserizale etc. I tried many methods but without success.

Error:
Uncaught (in promise) SyntaxError: Unexpected token '<', "<?xml vers"... is not valid JSON

Some methods I've tried:

var xml = (XmlReportSource)sourceReportSource;
var reportInstance = this.DeserializeReport(xml);
var ss = this.DeserializeReport(xml);

XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
var json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true);

I would be very happy if you could help with this.
enjoy your work.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Aug 2023, 07:24 AM

Hello Ayhan,

If I understand correctly, you would like to pull reports from your database which are stored as XML, is that correct?

Out of the box, Telerik Reporting offers only a file system-based storage for the Web Report Designer - FileDefinitionStorage, in order to design reports that are stored in a database, you would need to implement custom definition storage, please see the Implementing custom report definition storage for the web designer - Telerik Reporting article for more details on this topic.

A similar scenario is also covered in the MSSQL Server database as Reports Storage for Web Report Designer - Telerik Reporting KB article which is an example of how a custom definition storage can be implemented.

The reports are retrieved from the storage through the GetAsync(String) method so you need to get the XML from your database and return a byte array from it. 

I hope that the provided information will help, please let me know if you have any questions.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
AYHAN
Top achievements
Rank 1
commented on 28 Aug 2023, 12:54 PM | edited

Thanks for the answer. As you can see in the screenshot, the reports are stored in xml format in the database. These xml contents consist of the contents of files with trdx extension. I want this xml data to be opened and designed with the web report designer and saved back to the database. There is no physical trdx file in my system.

Dimitar
Telerik team
commented on 31 Aug 2023, 10:51 AM

Hello Ayhan,

In that case, you do indeed need to implement a custom storage that retrieves the reports' XML from the database. We have such an example that uses EF Core and an MSSQL database -  MSSQL Server database as Reports Storage for Web Report Designer - Telerik Reporting.

There is a sample project at the end of the article that you may download and run. However, the project uses DEV packages and since you have a trial license, you would need to replace those packages with the TRIAL ones which have a .Trial suffix.

Tags
Report Designer - Web Report Designer (standalone) Report Viewer - HTML5 Report Viewer - HTML5 WebForms
Asked by
AYHAN
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or