I would like to create a report like this:
I have a column called "hatalar". And if I click data in "hatalar" column,
I would like to open a new report.
New report should be like this:
How can I open a new report when I click data in report?
There are two main ways to do this, open in new window or 'drill through' to the next report in question.
New window: Create a javascript expression that checks whether the report is rendered as a report or excel/pdf and creates a link that will open a new window with the correct URL:
=IIF(Globals!RenderFormat.Name = "RPL", "javascript:void(window.open('http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=" & Fields!ReportMonthId.Value & "','_blank'))", "http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=" & Fields!ReportMonthId.Value)
Additional MS documentation on how to pass report parameters via the report URL can be found here but the gist is like this:
Native Mode URL:
http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=3&ReportYear=2008
SharePoint Mode URL:
http://myspsite/subsite/_vti_bin/reportserver?http://myspsite/subsite/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2.rdl&ReportMonth=3&ReportYear=2008
Drillthrough: Set the action of the hatalar textbox to 'drillthrough' and pass report parameters. This will result in the current page being replaced with the sub page.
Additional documentation can be found on the MS documentation page for drillthroughs.
Related
The problem:
I have an SSIS package that loops through 100+ Excel files and reads the data, then copies the contents over to a SQL Server Table. In these Excel files, this one column has hyperlinks. The column text itself says something like DSH-LN-4, but clicking on it in Excel opens up a folder that contains some images. How do I copy the underlying link in this column rather than the actual text in the cells?
What have I tried so far:
I haven't really tried anything because I found absolutely no resources on how to do this in SSIS. Manually adding a column to the Excel files is NOT possible, since there are 100's of files. The only resource I found was in this SO Question, but this does not indicate the process of doing this without manually manipulating the Excel files.
What I would like:
In my ForEach loop container, I have a data flow task that gets the Excel contents and shoves it into the SQL Table. The column that contains hyperlinks is called PhotoReference (since these hyperlinks open the folder that has the photos). I would like this PhotoReference column to copy over the underlying hyperlink of the cell and add that to the SQL column.
For instance, I want the PhotoReference column to contain this:
www.companyname.box.com/asjdfbgkjb134kjbsdafo2bm21n4bk
If I can manage to do this, my Power BI report running off of this underlying data could contain a clickable text that would open the image directly.
Any help would be appreciated.
UPDATE:
I was able to try two different methods to extract the hyperlinks from my column, but each of these have their own issues:
Method 1: I added a Script Task component to my ForEach container and as I loop through each Excel file, used Microsoft.Office.Interop.Excel.Hyperlinks assembly to get the hyperlink from my Excel column. BUT, I don't know what to do with it after. I figured the only thing to do is to overwrite the Excel columns' content with my extracted hyperlink, but I really rather not change my Excel files in any manner.
Method 2: I added a Script Component object inside my data flow task in between my Excel source and SQL Destination. In this method, I could not get nearly as far because the Input0_ProcessInputRow method that is auto-generated has the argument Row of type Input0Buffer. I am not able to apply any Microsoft.Office.Interop.Excel properties to my Input0Buffer object. So I am stuck.
If you have to right to alter the excel files, you can simply add a Script Task before the data flow task to replace the URL column value with the hyperlink.
In this answer, I will provide a step-by-step solution to solve this problem:
Creating Excel samples
First of all, I created some Excel files with the following columns:
First name (text)
Last name (text)
Age (number)
Photo (hyperlink)
The file content looks like the following:
Creating the SSIS package
First of all, You must add an Excel connection manager that link to one of the Excel files you need to import. And an OLE DB connection manager to connect to the SQL Server instance.
You must add a SSIS variable of type string, to store the Excel file path when using the foreach enumerator
Add a Foreach loop container and configure it to loop over the Excel files as mentioned in the images below:
Within the Foreach Loop container add a Script Task and a Data flow task as mentioned in the image below:
Now, Open the data flow task and add an Excel source and an OLE DB destination and configure the columns mapping between them.
Open the Script Task configuration, and select the ExcelFilePath variable (created in step 2) as a readonly variable as mentioned in the image below:
Now, open the Script editor and in the solution explorer window, right-click on the references icon and click on "Add Reference..."
When the Add reference catalog appears, click on the COM tab, and search for Excel, then you should select the Excel Object Library from the results as shown in the following image:
Also, make sure to add Microsoft.CSharp.dll reference.
On the top of the script you should add the following line:
using Excel = Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
In the Main() function add the following lines:
Excel.Application excel = new Excel.Application();
string originalPath = Dts.Variables["User::ExcelFilePath"].Value.ToString();
Excel.Workbook workbook = excel.Workbooks.Open(originalPath);
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets[1];
Excel.Range usedRange = worksheet.UsedRange;
int intURLColidx = 0;
excel.Visible = false;
excel.DisplayAlerts = false;
for (int i = 1; i <= usedRange.Columns.Count; i++)
{
if ((worksheet.Cells[1, i] as Excel.Range).Value != null &&
(string)(worksheet.Cells[1, i] as Excel.Range).Value == "Photo")
{
intURLColidx = i;
break;
}
}
for (int i = 2; i <= usedRange.Rows.Count; i++)
{
if ((worksheet.Cells[i, intURLColidx] as Excel.Range).Hyperlinks.Count > 0)
{
(worksheet.Cells[i, intURLColidx] as Excel.Range).Value2 = (worksheet.Cells[i, intURLColidx] as Excel.Range).Hyperlinks.Item[1].Address.ToString();
}
}
workbook.Save();
Marshal.FinalReleaseComObject(worksheet);
workbook.Close(Type.Missing, Type.Missing, Type.Missing);
Marshal.FinalReleaseComObject(workbook);
excel.Quit();
Marshal.FinalReleaseComObject(excel);
Dts.TaskResult = (int)ScriptResults.Success;
In the lines above, first we searched for the column index that contains the hyperlink (in this example the column name is "Photo", then we will check for each line if the Hyperlink address is not empty we will replace the column value with this hyperlink address)
Finally, make sure to configure the Excel connection manager to read the file path from the created variable value (Step 2) using expressions:
Experiments
After running the package, if we open an Excel file we will see that the Cell value is replaced with the URL:
And as shown in the image below, data are imported successfully to SQL Server:
References
Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert'
Extracting a URL from hyperlinked text in Excel cell
Excel interop prevent showing password dialog
What you will probably need to do is some hackery involving the Excel COM API, or macros. In fact, since you should stay away from using the Office COM API in SSIS.
You could pre-process excel to take that value with non-standard operations in SSIS, like using script component.
These are the steps you need to follow to import that data using the Script component:
Drag and drop a script component and select "source" as the script option type.
By default the script language is Microsoft Visual C# 2008 and I have done this sample with Microsoft Visual Basic 2008. Change this if you need to.
Define your output columns with the correct data type in "data type properties"
Edit the script. In the IDE you should add reference:
Microsoft.Excel 11.0 Object Library
(if that reference doesn´t work, try with Microsoft.Excel 5.0 Object Library)
Finally, write some code:
Imports Microsoft.Office.Interop.Excel
Public Overrides Sub getHyperlink()
Dim oExcel As Object = CreateObject("Excel.Application")
Dim FileName As String
FileName = Variables.FileName
Dim oBook As Object = oExcel.Workbooks.Open(FileName)
Dim oSheet As Object = oBook.Worksheets(1)
Output0Buffer.AddRow()
// change A1 with your correct col & row
Output0Buffer.Address = cell.range("A1").Hyperlinks(1).Address & "#" & cell.range("A1").Hyperlinks(1).SubAddress
End Sub
(keep in mind that it is a code that may not run, it is by way of illustration)
You could see code in C# here:
C# Script in SSIS Script Task to convert Excel Column in "Text" Format to "General"
The only issue with the script method is you need to have the Excel
runtime installed.
More about script component here:
https://www.tutorialgateway.org/ssis-script-component-as-transformation/
I created some reports in Visual Studio 2015 with all the latest updates. However, when I try to deploy the reports I get this message:
The definition of this report is not valid or supported by this version of Reporting Services.
11:40:28 Error
The report definition may have been created with a later version of Reporting Services, or contain content that is not
11:40:28 Error
well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target
11:40:28 Error
namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
The first lines of the .rdl file are set up like this:
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df"
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
Can I change the schema definition? If so, to what? I tried just changing 2016 to 2014 or 2012, but neither worked.
Is there a place I can go to see valid definitions?
I actually ran into a similar problem where a change I needed to make resulted in an "Undocumented Error/Invalid RDL Structure" error in 2016, so I edited the RDL file so I could open it in an earlier version and make my changes. Not too hard, but you need to make a couple of tag edits.
For new reports you should probably just use an older version, but for existing reports you can do this: (I reverted to 2008)
Change the Report tag:
Remove MustUnderstand="df"
Change the xmlns value to "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
Delete the xmlns:df attribute.
Delete the entire "ReportParametersLayout" block.
Delete the "df" tag and its content.
Delete the "ReportSections" and "ReportSection" opening and closing tags (not the content).
Actually wrote some superhackish code to do this as part of a blog post, but the manual edit is simple enough.
The settings below should be set to your sepecific version of SSRS, and then take the RDL from the \bin directory
Or, after updating the TargetServerVersion, simply use right click | deploy from the rdl.
The accepted answer is significantly more difficult/prone to error/unlikely to work across multiple versions of ssrs, and needs to be applied each time you change the rdl.
I had the same issue when switching to VS2017 and installed Report Designer Version 14.2.
For me only 3 steps needed to fix the issue.
1: Set Change the xmlns to "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
2: Remove ReportSections" and "ReportSection" (Only Tags).
3: Remove report ReportParametersLayout section.
The only thing you need to memorize is to point xmlns to 2008/01
Other 2 steps can be seen in the error message after you change to 2008/01 and try to run the report.
If you are having trouble in a Visual Studo 2017 C# desktop application with LocalReport (RDLC), please see this answer:
https://stackoverflow.com/a/45149488/6732525
I recently ran into this issue as well. I found that I only needed to change two items in the .rdl file in question.
Change FROM:
Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
TO:
Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"
Unlike other responses, I needed 2010 instead of 2008. I would check an .rdl file that you have already deployed.
Remove the "ReportParametersLayout" block.
Note: If I removed ReportSections block, it did not work as others have noted.
I ran in to same problem and this is how I solved it,
Set the "TargetServerVersion" property on report project properties to be your old version of reporting server.
Build the project.
Get the report in the bin folder and deploy to the old reporting server.
Your source reports format and namespace will be updated to latest version. But bin folder reports will be build to be compatible with targeted reporting server version.
I have automated this task.
create a form with a textbox named "TextBoxFile" and a button.
In the code of the click button:
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(TextBoxFile.Text)
Dim root = xmlDoc.DocumentElement
For Each elel As XmlNode In root.ChildNodes
Debug.WriteLine(elel.Name & " " & elel.NodeType)
Next
If root.Attributes()("xmlns").Value <> "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" Then
root.Attributes()("xmlns").Value = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
End If
Dim nsmgr = New XmlNamespaceManager(xmlDoc.NameTable)
nsmgr.AddNamespace("bk", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
Dim autoRefreshElements = root.GetElementsByTagName("AutoRefresh")
While autoRefreshElements.Count > 0
root.RemoveChild(autoRefreshElements(0))
End While
Dim ReportParametersLayout = root.GetElementsByTagName("ReportParametersLayout")
While ReportParametersLayout.Count > 0
root.RemoveChild(ReportParametersLayout(0))
End While
Dim ReportSections = root.GetElementsByTagName("ReportSections")
If ReportSections.Count > 0 Then
' Move content of ReportSections just below the block.
Dim ReportSection = ReportSections(0).ChildNodes()
' First, copy the elements after
Dim precedent = ReportSections(0)
For Each child As XmlNode In ReportSection(0).ChildNodes
Dim clone = child.Clone
root.InsertAfter(clone, precedent)
precedent = clone
Next
' After deleting the existing block
While ReportSections.Count > 0
root.RemoveChild(ReportSections(0))
End While
End If
xmlDoc.Save(TextBoxFile.Text)
MsgBox("Ok")
The most simple and straight forward solution. I would suggest you to find Microsoft.ReportingServices.ReportViewerControl.WebForms in Manage NuGet Packages of the current project and update this dll version to latest version.
Navigate from VS menu: Tools > NuGet Package Manager > Manage NuGet Packages for Solution
Login through the local admin account and correct computer objects by deleting and creating those computer objects.
I am developing a vb.net winform project that takes a persons photo ID. I want to store the location of the photo in a SQL Server database.
In the project, a persons details are taken (Name, Number, Address, etc) and stored in the database. I can do that part no problem. A photo is taken of the person and stored in a folder on one of the drives on the network. There is an option to choose a photo from this folder in the project and it is added to the profile.
What is the best way to get the location of the image and how do I go about storing it in the Sql server database? I want to be able to use the location of the photo to call it to use again in another part of the project. Any help with this problem would be greatly appreciated.
In your application, your going to want to use a "OpenFileDialog" so the user can choose the file. See example below:
Dim ofd As New OpenFileDialog
ofd.Filter = "*.png|PNG|*.jpg|JPEG" 'Add other exensions you except here
ofd.Title = "Choose your folder"
'ofd.InitialDirectory = "c:\SomeFolder..." 'If you want an initial folder that is shown, otherwise it will use the last folder used by this appliaction in an OFD.
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
'Something = ofd.FileName 'Do something with the result
End If
Then save the result of ofd.FileName in your table. This will be the full path and name of the file they selected.
I created report(XtraReport) and i drag reporting tool PrintBarManager or PrintControl to form. Now I need to load that report to that PrintControl. How to load ? Help me.
I tried this code but showing error - Object reference is not set to instance of object
var test = new XtraReport1();
printControl1.Container.Add(test); // Object reference not set to instance of object
test.ShowPreview();
I tried this code but it showing - Best overloaded method match.....
var test = new XtraReport1();
printControl1.Controls.Add(test); // Best overloaded method, invalid arguments
test.ShowPreview();
How to load my report to PrintControl ?
Use the following code:
//Set the printing system
printControl.PrintingSystem = report.PrintingSystem;
//Create and build your report
XtraReport1 report = new XtraReport1();
report.CreateDocument();
P.S. Take a look at How to: Add a Print Preview to a Windows Forms Application guidance.
I'm working on a data migration task, where I have to export a somewhat large Lotus Notes application into a blogging platform. My first task was to export the articles from Lotus Notes into CSV files.
I created a Agent in LotusScript to export the data into CSV files. I use a modified version of this IBM DeveloperWorks forum post. And it basically does the job. But the contents of the Rich Text field is stripped of any formatting. And this is not what I want, I want the Rich Text field rendered as HTML.
The documentation for the GetItemValue method explicitly states that the text is rendered into plain text. So I began to research for something that would retrieve the HTML. I found the NotesMIMEEntity class and some sample code in the IBM article How To Access HTML in a Rich Text Field Using LotusScript.
But for the technique described in the above article to work, the Rich Text field need to have the property "Store Contents as HTML and MIME". And this is not the case with my Lotus Notes database. I tried to set the property on the fields in question, but it didn't do the trick.
Is it possible to use the NotesMIMEEntity and set the "Store Contents as HTML and MIME" property after the content has been added, to export the field rendered as HTML?
Or what are my options for exporting the Notes database Rich Text fields as HTML?
Bonus information: I'm using IBM Lotus Domino Designer version 8.5
There is this fairly unknown command that does exactly what you want: retrieve the URL using the command OpenField.
Example that converts only the Body-field:
http://SERVER/your%5Fdatabase%5Fpath.nsf/NEW%5FVIEW/docid/Body?OpenField
Here is how I did it, using the OpenField command, see D.Bugger's post above
Function GetHtmlFromField(doc As NotesDocument, fieldname As String) As String
Dim obj
Set obj = CreateObject("Microsoft.XMLHTTP")
obj.open "GET", "http://www.mydomain.dk/database.nsf/0/" + doc.Universalid + "/" + fieldname + "?openfield&charset=utf-8", False, "", ""
obj.send("")
Dim html As String
html = Trim$(obj.responseText)
GetHtmlFromField = html
End Function
I'd suggest looking at Midas' Rich Text LSX (http://www.geniisoft.com/showcase.nsf/MidasLSX)
I haven't used the personally, but I remember them from years ago being the best option for working with Rich Text. I'd bet it saves you a lot of headaches.
As for the NotesMIMEEntity class, I don't believe there is a way to convert RichText to MIME, only MIME to RichText (or retain the MIME within the document for emailing purposes).
If you upgrade to Notes Domino 8.5.1 then you can use the new ConvertToMIME method of the NotesDocument class. See the docs. This should do what you want.
Alternativly the easiest way to get the Domino server to render the RichText will be to actually retrieve it via a url call. Set up a simple form that just has the RichText field and then use your favourite HTTP api to pull in the page. It should then be pretty straight forward to pull out the body.
Keep it simple.
Change the BODY field to Store contents as HTML and MIME
Open the doc in editmode.
Save.
Close.
You can now use the NotesMIMEEntity to get what you need from script.
You can use the NotesDXLExporter class to export the Rich Text and use an XSLT to transform the output to what you need.
I know you mentioned using LotusScript, but if you don't mind writing a small Java agent (in the Notes client), this can be done fairly easily - and there is no need to modify the existing form design.
The basic idea is to have your Java code open a particular document through a localhost http request (which is simple in Java) and to have your code capture that html output and save it back to that document. You basically allow the Domino rendering engine to do the heavy lifting.
You would want do this:
Create a form which contains only the rich-text field you want to convert, and with Content Type of HTML
Create a view with a selection formula for all of the documents you want to convert, and with a form formula which computes to the new form
Create the Java agent which just walks your view, and for each document gets its docid, opens a URL in the form http://SERVER/your_database_path.nsf/NEW_VIEW/docid?openDocument, grabs the http response and saves it.
I put up some sample code in a similar SO post here:
How to convert text and rich text fields in a document to html using lotusscript?
Works in Domino 10 (have not tested with 9)
HTMLStrings$ = NotesRichTextItem .Converttohtml([options] ) As String
See documentation :
https://help.hcltechsw.com/dom_designer/10.0.1/basic/H_CONVERTOHTML_METHOD_NOTESRICHTEXTITEM.html
UPDATE (2022)
HCL no longer support this method since version 11. The documentation does not include any info about the method.
I have made some tests and it still works in v12 but HCL recommended to not use it.
Casper's recommendation above works well, but make sure the ACL is such to allow Anonymous Access otherwise your HTML will be the HTML from your login form
If you do not need to get the Richtext from the items specifically, you can use ?OpenDocument, which is documented (at least) here: https://www.ibm.com/developerworks/lotus/library/ls-Domino_URL_cheat_sheet/
https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/com.ibm.designer.domino.main.doc/H_ABOUT_URL_COMMANDS_FOR_OPENING_DOCUMENTS_BY_KEY.html
OpenDocument also allows you to expand sections (I am unsure if OpenField does)
Syntax is:
http://Host/Database/View/DocumentUniversalID?OpenDocument
But be sure to include the charset parameter as well - Japanese documents were unreadable without specifying utf-8 as the charset.
Here is the method I use that takes a NotesDocument and returns the HTML for the doc as a string.
private string ConvertDocumentToHml(Domino.NotesDocument doc, string sectionList = null)
{
var server = doc.ParentDatabase.Server.Split('/')[0];
var dbPath = doc.ParentDatabase.FilePath;
string viewName = "0";
string documentId = doc.UniversalID.ToUpper();
var ub = new UriBuilder();
ub.Host = server;
ub.Path = dbPath.Replace("\\", "/") + "/" + viewName + "/" + documentId;
if (string.IsNullOrEmpty(sectionList))
{
ub.Query = "OpenDocument&charset=utf-8";
}
else
{
ub.Query = "OpenDocument&charset=utf-8&ExpandSection=" + sectionList;
}
var url = ub.ToString();
var req = HttpWebRequest.CreateHttp(url);
try
{
var resp = req.GetResponse();
string respText = null;
using (var sr = new StreamReader(resp.GetResponseStream()))
{
respText = sr.ReadToEnd();
}
return respText;
}
catch (WebException ex)
{
return "";
}
}