如果要製作出下圖表格,可以利用原廠的程式碼稍微修改
這樣就能在料號的報表中使用
如果選三個料號也能一次顯示
那麼就來解說一下該如何設定
1.先將Part的報表新增完成,並將提供的程式碼填寫上去
2.將XSLT更新
3.確認欄位並微調
4.完成
參考程式碼
https://github.com/panda0909/Aras-PLM-Exercise/tree/master/Report/Multiple%20Level%20BOM%20R1_R2
注意
jpc_getMutipleBOMLevel.c有一段邏輯解決一個問題,系統將小位數超過6位時變成科學記號,這裡我將科學記號還原回來
private string ConvertNumber(string qStr){
Decimal de;
Decimal.TryParse(qStr,System.Globalization.NumberStyles.Any,null,out de);
return de.ToString();
}
Item part = inn.applyAML(aml);
Item bom = part.getItemsByXPath("//Item[@type='Part BOM']");
for(int i=0;i<bom.getItemCount();i++){
Item b = bom.getItemByIndex(i);
string qStr = b.getProperty("quantity","0");
b.setProperty("quantity",ConvertNumber(qStr));
qStr = b.getProperty("cn_attrition_rate","0");
b.setProperty("cn_attrition_rate",ConvertNumber(qStr));
}
bom = part.getItemsByXPath("//Item[@type='BOM Substitute']");
for(int i=0;i<bom.getItemCount();i++){
Item b = bom.getItemByIndex(i);
string qStr = b.getProperty("cn_substitute_quantity","0");
b.setProperty("cn_substitute_quantity",ConvertNumber(qStr));
qStr = b.getProperty("cn_substitute_shrinkrate","0");
b.setProperty("cn_substitute_shrinkrate",ConvertNumber(qStr));
}
XSLT 有增加下載按鈕,可以參考右上角Export按鈕
<script>
<![CDATA[
function fnExcelReport()
{
var tab_text="<meta http-equiv='content-type' content='application/vnd.ms-excel; charset=UTF-8'/><table border='2px'download='Part'><tr>";
var textRange; var j=0;
tab = document.getElementById('headerTable'); // id of table
for(j = 0 ; j < tab.rows.length ; j++)
{
tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
//tab_text=tab_text+"</tr>";
}
tab_text=tab_text+"</table>";
tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1.document.open("txt/html","replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa=txtArea1.document.execCommand("SaveAs",true,"Part");
}
else //other browser not tested on IE 11
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
return (sa);
}
]]>
</script>