Javascript to generate excel 2

來源:互聯網
上載者:User
using System;using CCC.Utility;namespace CCC.BLL{/// <summary>/// Summary description for JVExcelBuilder./// </summary>public class JVExcelBuilder{private const int detailGridRowStart= 11;private const int detailGridColumnStart= 2; private const int jvGridRowStart= 21;private const int jvGridColumnStart= 4;private int jvCombGridRowStart= 31;private const int jvCombGridColumnStart= 7;private Excel4JavaScript excel;private int detailGridCurrentRow;private int jvGridCurrentRow;private int jvCombGridCurrentRow;private int currentJVSheetIndex;public JVExcelBuilder(string strFileName, int originalSheetCount){excel = new Excel4JavaScript(strFileName, originalSheetCount);detailGridCurrentRow = detailGridRowStart;jvGridCurrentRow = jvGridRowStart;jvCombGridCurrentRow = jvCombGridRowStart;currentJVSheetIndex = 2;}public string ToExcelString(){return excel.ToExcelString();}#region Detail sheetpublic void WriteDetailHeader1(string month, string rate){string cellValue = string.Format("Accural rate of  Month ({0}) from RMB to USD : {1}", month, rate);excel.WriteComment( cellValue, 5, 2, 1);}public void WriteDetailHeader2(string month, string rate){string cellValue = string.Format("Accural rate of  Month ({0}) from HKD to USD : {1}", month, rate);excel.WriteComment( cellValue, 6, 2, 1);}public void WriteDetailGridRow(params string[] strValues){if( detailGridCurrentRow > detailGridRowStart )excel.InsertRow( detailGridCurrentRow+1, 1 );int currentColumn = detailGridColumnStart;foreach( string strValue in strValues ){excel.WriteComment( strValue.Replace("'", "\\'"), detailGridCurrentRow, currentColumn, 1);currentColumn++;}detailGridCurrentRow++;}public void DeleteLastDetailGridRow(){excel.DeleteRows(detailGridCurrentRow, 1);}#endregion#region JV Sheetpublic void SetFirstJVSheetName(string strWorkSheetName){excel.SetWorkSheetName(2,strWorkSheetName);}public void CopyJVSheets(string sheetName){excel.CopyWorkSheet(currentJVSheetIndex, sheetName);currentJVSheetIndex++;}public void WriteJVAccountDate(int sheetIndex, DateTime date){excel.WriteComment(date.ToString("MM/dd/yyyy"),9, 11, sheetIndex+1);}public void WriteJVBatchName(int sheetIndex, string strValue){excel.WriteComment(strValue, 10, 11, sheetIndex+1);}public void WriteJVJournalName(int sheetIndex, string strValue){excel.WriteComment(strValue, 11, 11, sheetIndex+1);}public void WriteJVJournalDesc(int sheetIndex, string strValue){excel.WriteComment(strValue, 12, 11, sheetIndex+1);}public void WriteJVJournalPeriod(int sheetIndex, string strValue){excel.WriteComment(strValue, 14, 11, sheetIndex+1);}public void WriteJVGridRow(int sheetIndex, params string[] strValues){if( jvGridCurrentRow > jvGridRowStart )excel.InsertRow( jvGridCurrentRow+1, sheetIndex+1 );int currentColumn = jvGridColumnStart;foreach( string strValue in strValues ){excel.WriteComment( strValue.Replace("'", "\\'"), jvGridCurrentRow, currentColumn, sheetIndex+1);currentColumn++;}jvGridCurrentRow++;}/// <summary>/// the index of JV sheets/// </summary>/// <param name="sheetIndex"></param>public void HideJVTemplateSheet(int sheetIndex){excel.HideSheet(sheetIndex+1);}public void DeleteLastJVGridRow(int sheetIndex){if( jvGridCurrentRow == jvGridRowStart ){excel.DeleteRows(jvGridCurrentRow+1, sheetIndex+1);jvCombGridRowStart += jvGridCurrentRow - jvGridRowStart - 1;}else{excel.DeleteRows(jvGridCurrentRow, sheetIndex+1);jvCombGridRowStart += jvGridCurrentRow - jvGridRowStart -2;}jvCombGridCurrentRow = jvCombGridRowStart;}public void WriteJVCombGridRow(int sheetIndex, params string[] strValues){if( jvCombGridCurrentRow > jvCombGridRowStart + 1 )excel.InsertRow( jvCombGridCurrentRow+1, sheetIndex+1 );int currentColumn = jvCombGridColumnStart;foreach( string strValue in strValues ){excel.WriteComment( strValue.Replace("'", "\\'"), jvCombGridCurrentRow, currentColumn, sheetIndex+1);currentColumn++;}jvCombGridCurrentRow++;}public void DeleteLastJVCombGridRow(int sheetIndex){if( jvCombGridCurrentRow - jvCombGridRowStart > 2 ){excel.DeleteRows(jvCombGridCurrentRow, sheetIndex+1);}jvGridCurrentRow = jvGridRowStart;jvCombGridRowStart = 31;jvCombGridCurrentRow = jvCombGridRowStart;}public void WriteJVTotalJournalVouchers(int sheetIndex, int count){excel.WriteComment( "(Total: " + count.ToString() + " Journal vouchers)", jvCombGridRowStart+1, 9, sheetIndex+1);}public void WriteJVTruckerCode(int sheetIndex, string truckerCode){excel.WriteComment( truckerCode, jvCombGridRowStart, 12, sheetIndex+1);}#endregion}}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.