2015年12月26日 星期六

How to define Body Size in Report Viewer ? (Visual studio 2010)

引用

create Report Viewer in my ASP.net project(.rdlc file) and I have problem when I export it to PDF.(I got extra blank page for every page). I read a solution that I have to change the Body Size. Body ->Properties -> Size .., but I can't find size in Body Properties. That's the option I have there: (only Fill and Border)
Here is a picture
You can set Body size by left-clicking on body area and pressing F4.
You also have to set Report Size and Margins by right-clicking outside your report (grey area).
Note that Report size include Margins so you have to set Body size according to this; i.e. Body.Width = Report.Width - Report.Margins.Right - Report.Margins.Left

2015年12月25日 星期五

How-to-add-Cross-Browser-Printing-to-ASP-NET-ReportViewer-toolbar

http://www.neodynamic.com/articles/How-to-add-Cross-Browser-Printing-to-ASP-NET-ReportViewer-toolbar/

引用

In this article I will explain how to hide (disable) specific export option i.e. Word, Excel or PDF from the export button DropDown in RDLC (Local SSRS) ReportViewer control.
By default the RDLC (Local SSRS) ReportViewer control displays all the three export options i.e. Word, Excel or PDF and hence in order to hide a specific export option, one has to make use of Reflection.
 
Creating and populating RDLC Report using ReportViewer from Database
I have already explained how to create and populate RDLC Report using ReportViewer control from database in my following article.
 
Hide (Disable) specific export option (Word / Excel / PDF) from Export button DropDown
We will be using ReportViewer control’s OnLoad event handler and hence we need to assign an OnLoad event handler to the ReportViewer control as shown below.
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600" OnLoad="ReportViewer_OnLoad">
</rsweb:ReportViewer>
 
Then inside the event handler we will write code to hide the Export option in the export button DropDown.
All the export options in ReportViewer control are available through the ListRenderingExtentionsList method. From this list we need to find the extension of the Export option we wish to hide, thus I have done that by matching the extension name in the Lambda expression query.
Once the extension is found we need to access its m_isVisible property using Reflection and set it to false.
C#
protected void ReportViewer_OnLoad(object sender, EventArgs e)
{
    //string exportOption = "Excel";
    //string exportOption = "Word";
    string exportOption = "PDF";
    RenderingExtension extension = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));
    if (extension != null)
    {
        System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        fieldInfo.SetValue(extension, false);
    }
}
 
VB.Net
Protected Sub ReportViewer_OnLoad(sender As Object, e As EventArgs)
    'string exportOption = "Excel";
    'string exportOption = "Word";
    Dim exportOption As String = "PDF"
    Dim extension As RenderingExtension = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(Function(x) x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase))
    If extension IsNot Nothing Then
        Dim fieldInfo As System.Reflection.FieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
        fieldInfo.SetValue(extension, False)
    End If
End Sub
 
 
Screenshot
The following screenshot displays the Report Viewer control with the hidden PDF export option.
ASP.Net RDLC (Local SSRS) Report Viewer: Hide (Disable) specific export option (Word / Excel / PDF) from Export button

FOR XML [MSSQL]將多筆資料合併為一筆顯示(FOR XML PATH)

SELECT m.LOT ,left(m.TEMP_ARTICLE_NO,len(m.TEMP_ARTICLE_NO)-1) as ARTICLE_NO from (
SELECT LOT,(SELECT TEMP_ARTICLE_NO + ',' from 
(SELECT LOT,TEMP_ARTICLE_NO FROM YARN_IN_D WHERE YYYYMM='201608' AND STATUS<>'D' GROUP BY LOT,TEMP_ARTICLE_NO) a1 
where LOT = ord.LOT
FOR XML PATH('')) as TEMP_ARTICLE_NO
from (SELECT LOT FROM YARN_IN_D WHERE YYYYMM='201608' AND STATUS<>'D' GROUP BY LOT) ord
GROUP BY LOT
) M 
ORDER by M.lot


SELECT cast(批號 AS NVARCHAR ) + ',' from [批號] 
FOR XML PATH('')

用北風資料庫舉例
step1:先讓我們看看orderID = '10248'的產品有哪些

SELECT * FROM [Order Details] 
where OrderID = '10248'
有這些
step2:然後我們利用for xml path把他合併顯示

SELECT cast(ProductID AS NVARCHAR ) + ',' from [Order Details] 
where OrderID = '10248'
FOR XML PATH('')
輸出是這樣,可以發現果然productID都合併了
step3:然後改成顯示所有的order的productID

SELECT OrderID,(SELECT cast(ProductID AS NVARCHAR ) + ',' from [Order Details] 
where OrderID = ord.OrderID
FOR XML PATH('')) as productIDs
from orders ord
GROUP BY orderid
輸出像是這樣,所有的order的productID,但是productID還多一個逗號
step4:最後動些手腳,輸出就完美了,成功的將多筆資料合併為一筆

SELECT m.OrderID ,left(m.productIDs,len(m.productIDs)-1) as productIDsFinal from 
(SELECT OrderID,(SELECT cast(ProductID AS NVARCHAR ) + ',' from [Order Details] 
where OrderID = ord.OrderID
FOR XML PATH('')) as productIDs
from orders ord
GROUP BY orderid) M --這個M一定要加,不知道為啥
ORDER by M.OrderID 
最後輸出:

2015年12月11日 星期五

網頁無法正常顯示字型

網頁在顯示繁體中文之外的字體
都會出現一堆黑色實心的長方形、直線
我選取檢視.編碼.自動選取.都不行(有支援字型)
另外,視窗又上方的縮小、還原、關閉
都變成 0 2 r ,有箭號的地方都變不正常了(變6 或 8)

系統是win98嗎
如果是的話用搜尋去找一隻檔案叫ttfcache
他是一隻隱藏檔
你要在安全模式下將他砍掉
重開機之後因該就恢復正常了

哪個語系的網頁字型?目前琥珀的簽名檔有使用到韓文字型,如果沒有安裝任何一種韓文字型,Win98/Me會顯示「框框框」,Win2000/XP可能是空白。
開機時,按下CTRL不放,選擇安全模式(Safe mode)。