sharepointで使用するexcelレポートコンポーネントorg.in2bits.MyXls

20299 ワード

呼び出し方法は次のとおりです.
public void GenBudgetRpt(FinBudgetBalanceRptDTO rptObject)
{
rptObject.RptName = "Report name : Budget Balance report";
string formatDate = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
rptObject.CutoffDate = "Cut off date: " + formatDate;
rptObject.Department = "Department: " + rptObject.Department;
XlsReportManager.Send<FinBudgetBalanceRptDTO>(rptObject);
}
[Serializable]
public class FinBudgetBalanceRptDTO
{
public string RptName { get; set; }
public string CutoffDate { get; set; } // temporarliy use LastUpdatedDate
public string Department { get; set; }
public List<FinBudgetBalanceDTO> BudgetBalanceDTOs { get; set; }
}

XlsReportStyleManagerとXlsReportManagerは添付ファイルを参照してください.
XlsReportManagerが呼び出すxmlファイルを次に示します.
<xsl-report name="FIN Budget Summary" type="Report.FinBudgetBalanceRptDTO">
<XF name="XF1">
<Font Bold="true"/>
</XF>
<XF name="XF2">
<Font Bold="true"/>
<HorizontalAlignment value="Centered"/>
</XF>
<XF name="XF3">
<HorizontalAlignment value="Right"/>
</XF>
<Worksheet name="Budgets Report">
<ColumnInfo ColumnIndexStart="0" ColumnIndexEnd="7" Width="4500"></ColumnInfo>
<Cells>
<cell row="1" column="1">
<value name="RptName"/>
</cell>
<cell row="2" column="1">
<value name="CutoffDate"/>
</cell>
<cell row="3" column="1">
<value name="Department"/>
</cell>
<cell row="5" column="1" XF="XF1">Budget code</cell>
<cell row="5" column="2" XF="XF1">Budget name</cell>
<cell row="5" column="3" XF="XF1">Budget owner</cell>
<cell row="5" column="4" XF="XF2">Total budget</cell>
<cell row="5" column="5" XF="XF2">Total ER approved</cell>
<cell row="5" column="6" XF="XF2">ER in process</cell>
<cell row="5" column="7" XF="XF2">Budget balance</cell>
<cell row="5" column="8" XF="XF2">Budget Available</cell>
<muti-cell beginRow="6" column="1">
<list name="BudgetBalanceDTOs" item="BudgetCode"/>
</muti-cell>
<muti-cell beginRow="6" column="2">
<list name="BudgetBalanceDTOs" item="BudgetName"/>
</muti-cell>
<muti-cell beginRow="6" column="3">
<list name="BudgetBalanceDTOs" item="BudgetOwner"/>
</muti-cell>
<muti-cell beginRow="6" column="4" XF="XF3">
<list name="BudgetBalanceDTOs" item="TotalBudget"/>
</muti-cell>
<muti-cell beginRow="6" column="5" XF="XF3">
<list name="BudgetBalanceDTOs" item="TotalERApproved"/>
</muti-cell>
<muti-cell beginRow="6" column="6" XF="XF3">
<list name="BudgetBalanceDTOs" item="ERInProcess"/>
</muti-cell>
<muti-cell beginRow="6" column="7" XF="XF3">
<list name="BudgetBalanceDTOs" item="BudgetBalance"/>
</muti-cell>
<muti-cell beginRow="6" column="8" XF="XF3">
<list name="BudgetBalanceDTOs" item="BudgetAvailable"/>
</muti-cell>
</Cells>
</Worksheet>
</xsl-report>

MyXls.zip BTW、ボタンをクリックしてxlsをエクスポートした後、どんなボタンを押してもそこで死ぬ、解決方法、ボタンに下scriptを加える:
function PosExport(obj,msg) {
if (!confirm(msg))
return false;
_spOriginalFormAction = obj.form.action;
_spSuppressFormOnSubmitWrapper = true;
return true;
}