private void AddInventoryFileHeader(Excel._Worksheet workSheet) { workSheet.Cells[4, 1].Value = "BÁO CÁO NHẬP XUẤT TỒN"; workSheet.Range(workSheet.Cells[4, 1], workSheet.Cells[4, 13]).Merge(); workSheet.Cells[5, 1].Value = "Kho: Phối liệu"; workSheet.Range(workSheet.Cells[5, 1], workSheet.Cells[5, 13]).Merge(); workSheet.Range(workSheet.Cells[4, 1], workSheet.Cells[5, 1]).Font.Size = 15; workSheet.Cells[6, 1].Value = "Kỳ: Tháng " + this.creatingTime; workSheet.Cells[6, 1].Font.Size = 10; workSheet.Range(workSheet.Cells[6, 1], workSheet.Cells[6, 13]).Merge(); workSheet.Range(workSheet.Cells[4, 1], workSheet.Cells[8, 13]).Font.Bold = true; workSheet.Range(workSheet.Cells[4, 1], workSheet.Cells[8, 13]).HorizontalAlignment = XlHAlign.xlHAlignCenter; workSheet.Range(workSheet.Cells[4, 1], workSheet.Cells[8, 13]).VerticalAlignment = XlHAlign.xlHAlignCenter; workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]).Font.Size = 8; workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]).Borders[XlBordersIndex.xlInsideVertical].Weight = XlBorderWeight.xlThin; workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]).Borders[XlBordersIndex.xlInsideVertical].LineStyle = XlLineStyle.xlContinuous; workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]).Borders[XlBordersIndex.xlInsideHorizontal].Weight = XlBorderWeight.xlThin; workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]).Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlContinuous; BorderAround(workSheet.Range(workSheet.Cells[7, 1], workSheet.Cells[8, 13]), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)); workSheet.Range(workSheet.Cells[7, 5], workSheet.Cells[5, 12]).Font.Size = 8; }
public static Excel.Range GetRange(ref Excel._Worksheet Sheet, string FirstColumn, int FirstRow, string LastColumn, int LastRow) { return(Sheet.get_Range(string.Format("{0}{1}", FirstColumn, FirstRow), string.Format("{0}{1}", LastColumn, LastRow))); }
/// <summary> /// Returns the specified range object /// </summary> /// <param name="Sheet">Excel Worksheet reference</param> /// <param name="FirstColumn">Range's first columns's identifier, in case of a number this is a 1 based index.</param> /// <param name="FirstRow">Range's first row's identifier, in case of a number this is a 1 based index.</param> /// <param name="LastColumn">Range's last column's identifier, in case of a number this is a 1 based index.</param> /// <param name="LastRow">Range's last row's identifier, in case of a number this is a 1 based index.</param> /// <returns></returns> public static Excel.Range GetRange(ref Excel._Worksheet Sheet, int FirstColumn, int FirstRow, int LastColumn, int LastRow) { return(Sheet.get_Range(string.Format("{0}{1}", GetColumnLetter(FirstColumn - 1), FirstRow), string.Format("{0}{1}", GetColumnLetter(LastColumn - 1), LastRow))); }