Adding custom save
Adding custom save
Is it possible to add my own Save type to the previewer? I like the variety of Save types that come with the product, but my company also needs the ability to Save the report in a propriatary format.
Adding custom save
Hello.
Please inherit your export from the StiExportService class and register the service with the command StiConfig.Services.Add (yourExportService);
If done correctly, your export will appear in the menu.
Thank you.
Please inherit your export from the StiExportService class and register the service with the command StiConfig.Services.Add (yourExportService);
If done correctly, your export will appear in the menu.
Thank you.
Adding custom save
I had tried that beforeand could not get it work. It will not appear in the Save menu.
StiReport report = new StiReport();
StiConfig.Services.Add(new MyExportService(), false);
// I used svcContainer below to verify the service was indeed added. It was added but does not appear in Save menu.
Stimulsoft.Base.Services.StiServiceContainer svcContainer = StiExportService.GetExportServices();
// My export service. It doesn't do anything yet. I first wanted to make sure "Save Unformatted" appears in the Save menu - it does not.
public class MyExportService : StiExportService
{
private StiExportFormat m_Format = new StiExportFormat();
public override string DefaultExtension
{
get { return "txt"; }
}
public override void Export(StiReport report, string file, bool sendEMail, Stimulsoft.Base.StiGuiMode guiMode)
{
}
public override StiExportFormat ExportFormat
{
get { return m_Format; }
}
public override string ExportNameInMenu
{
get { return "Save Unformatted"; }
}
public override string GetFilter()
{
throw new NotImplementedException();
}
public override string GroupCategory
{
get { return "Word"; }
}
public override int Position
{
get { return 50; }
}
public override Type ServiceType
{
get { return typeof(StiExportService); }
}
}
StiReport report = new StiReport();
StiConfig.Services.Add(new MyExportService(), false);
// I used svcContainer below to verify the service was indeed added. It was added but does not appear in Save menu.
Stimulsoft.Base.Services.StiServiceContainer svcContainer = StiExportService.GetExportServices();
// My export service. It doesn't do anything yet. I first wanted to make sure "Save Unformatted" appears in the Save menu - it does not.
public class MyExportService : StiExportService
{
private StiExportFormat m_Format = new StiExportFormat();
public override string DefaultExtension
{
get { return "txt"; }
}
public override void Export(StiReport report, string file, bool sendEMail, Stimulsoft.Base.StiGuiMode guiMode)
{
}
public override StiExportFormat ExportFormat
{
get { return m_Format; }
}
public override string ExportNameInMenu
{
get { return "Save Unformatted"; }
}
public override string GetFilter()
{
throw new NotImplementedException();
}
public override string GroupCategory
{
get { return "Word"; }
}
public override int Position
{
get { return 50; }
}
public override Type ServiceType
{
get { return typeof(StiExportService); }
}
}
Adding custom save
Hello,
We have checked our code.
Unfortunately, at this moment, you must register a new service in place of an existing service.
Please inherit your export from some service (for example, the StiRtfExportService class), use the following code to disable base service and register your service:
Thank you.
We have checked our code.
Unfortunately, at this moment, you must register a new service in place of an existing service.
Please inherit your export from some service (for example, the StiRtfExportService class), use the following code to disable base service and register your service:
Code: Select all
StiConfig.Load();
foreach (StiService service in StiConfig.Services)
{
if (service is StiRtfExportService)
{
service.ServiceEnabled = false;
break;
}
}
StiConfig.Save();
StiConfig.Services.Add(new MyExportService(), false);
Adding custom save
That didn't seem to work either. It removed Rtf from the Save menu as I would expect, but it did not add my export service. I even have a breakpoint in my export service's ExportNameInMenu method and it never gets called.
Is it possible to to change the text in another export service and re-direct its export handler to one of mine? For example, I could do without the "Open Document" service, so could I rename it to my "Save Unformatted"? How would I direct its Export callback to my own?
Is it possible to to change the text in another export service and re-direct its export handler to one of mine? For example, I could do without the "Open Document" service, so could I rename it to my "Save Unformatted"? How would I direct its Export callback to my own?
Adding custom save
Hello,
Due to some technical problems some time ago the code of the StiViewerControl class has been changed, and now in the exports menu only a pre-determined list of exports is displayed.
To add your exports, you need to inherit your export from one of the standard exports, disable this standard export service in the StiConfig class, and then add your export.
Building a menu of exports made in the constructor StiViewerControl, thus adding its exports have to call the constructor of the StiViewerControl class.
We have verified and it works correctly.
Thank you.
Due to some technical problems some time ago the code of the StiViewerControl class has been changed, and now in the exports menu only a pre-determined list of exports is displayed.
To add your exports, you need to inherit your export from one of the standard exports, disable this standard export service in the StiConfig class, and then add your export.
Building a menu of exports made in the constructor StiViewerControl, thus adding its exports have to call the constructor of the StiViewerControl class.
We have verified and it works correctly.
Thank you.
Adding custom save
Do you have any sample code? I am not using StiViewerControl. This is what I am doing.
StiReport report = new StiReport();
StiConfig.Load();
foreach (Stimulsoft.Base.Services.StiService service in StiConfig.Services)
{
if (service is StiRtfExportService)
{
service.ServiceEnabled = false;
break;
}
}
StiConfig.Save();
StiConfig.Services.Add(new MyExportService(), false);
report.ShowWithRibbonGUI(true);
StiReport report = new StiReport();
StiConfig.Load();
foreach (Stimulsoft.Base.Services.StiService service in StiConfig.Services)
{
if (service is StiRtfExportService)
{
service.ServiceEnabled = false;
break;
}
}
StiConfig.Save();
StiConfig.Services.Add(new MyExportService(), false);
report.ShowWithRibbonGUI(true);
Adding custom save
Hello,
We have checked everything and your code works correctly.
Perhaps you forgot to change the class inheritance:
public class MyExportService: StiRtfExportService
also check this on the latest prerelease build.
Thank you.
We have checked everything and your code works correctly.
Perhaps you forgot to change the class inheritance:
public class MyExportService: StiRtfExportService
also check this on the latest prerelease build.
Thank you.
Adding custom save
I am still using 2010.3. I will try it in the latest production release. If that doesn't work I will then try the pre-release. My company is hesitant on using non-production software so I want to see if it works in 2011.1 first.
Adding custom save
Hello,
Ok! Let us know about the result.
Thank you.
Ok! Let us know about the result.
Thank you.