俄文翻譯翻譯社

//拔取篇
mSheet.Cells.EntireColumn                                       //所有欄
mSheet.Cells.EntireRow                                          //所有列
mSheet.Cells                                                    //所有貯存格
mSheet.Columns[1]                                               //第一欄
mSheet.Rows[1]                                                  //第一列
mSheet.Cells[r,c]                                               //第r列第c欄
mSheet.Range[起,迄]                                             //區間選擇(起迄可以是欄、列、格)

mSheet.Cells[1].Interior.ColorIndex := 38;                      //設定底色為玫瑰色
mSheet.Cells[1].Interior.ColorIndex := 6;                       //設定底色為黃色
mSheet.Cells[1].Interior.ColorIndex := 36;                      //設定底色為淺黃色
mSheet.Cells[1].Interior.ColorIndex := 35;                      //設定底色為淺綠色

mSheet.Outline.ShowLevels(2);                                    //把小計層級設2顯示

//填值篇
mSheet.Cells[1,1].Value:= '內容';                               //欄位填值
mSheet.Cells[1,1].Formula:= '公式';                             //欄位填入公式
mSheet.Cells[1,1].FormulaR1C1:= '公式';                         //欄位填入公式
mSheet.Cells[1,1].HasFormula                                    //儲存格是不是有公式

//Workbook篇
mWorkBook := mExcel.WorkBooks[1];                               //將指定變數設定第一個活頁簿(數字可以用名稱取代)
mWorkBook.Name :='內容';                                        //變動WorkBook名稱
mExcel.WorkBooks.Add;                                           //新增一個空白活頁簿
mExcel.WorkBooks.Open(完整路徑);                                //開啟Excel檔
mExcel.WorkBooks[mFile].Close;                                  //封閉Excel檔
DeleteFile(mPath+mFile);                                        //刪除Excel檔
mWorkBook.SaveAs(mPath+mFile翻譯社-4143);                            //貯存Excel檔

//資料篇
mSheet.Cells.EntireColumn.AutoFilter;                           //自動挑選

//Excel篇
mExcel.DisplayAlerts := False;                                  //Disable 提醒訊息
mExcel.Visible := True;                                         //顯示 Excel 畫面
mExcel.ActiveWindow.FreezePanes := True;                        //凍結窗格(上一行一定要先選列或格)
mExcel.ActiveWindow.Zoom := 75;                                 //顯示比率為75%
mExcel.ActiveWindow.Zoom := True;                               //根據今朝選擇範圍主動決定視窗巨細

mSheet.Columns[1].NumberFormatLocal := '@';                     //設定欄位花式[文字]
mSheet.Columns[1].NumberFormatLocal := '#,##0_ ';               //設定欄位格局[數值(整數位 三位一撇)]
mSheet.Columns[1].NumberFormatLocal := '#翻譯社##0_ ;[紅色]-#翻譯社##0 '; //設定欄位格局[數值(整數位 三位一撇 負數紅字)]
mSheet.Columns[1].NumberFormatLocal := '#,##0_);[紅色](#,##0)'; //設定欄位格式[數值(整數位 三位一撇 負數括號紅字)]
mSheet.Columns[1].NumberFormatLocal := '0.00_ ';                //設定欄位格局[數值(小數兩位)]
mSheet.Columns[1].NumberFormatLocal := '0.0_);[紅色](0.0)';     //設定欄位花樣[數值(小數一名 負數紅字)]
mSheet.Columns[1].NumberFormatLocal := '0.00%';                 //設定欄位格局[百分比(小數兩位)]

//設定格式化條件
mSheet.Cells[1翻譯社1].FormatConditions.Delete;                      //消滅格式化前提
mSheet.Cells[1翻譯社1].FormatConditions.Add[Type:='1', Operator:='1', Formula1:='1', Formula2:='2']; //新增格式化前提(最多3個)
//參數說明
//  參數   中文申明                                  申明
//======== ======== =======================================================================
//Type     濫觞型態 1.貯存格的值 2.公式
//Operator 劃定規矩     1.介於 2.不介於 3.等於 4.不等於 5.大於 6.小於 7.大於或等於 8.小於或等於
//Formula1 前提起
//Formula2 條件迄
mSheet.Cells[1翻譯社1].FormatConditions(1).Interior.ColorIndex := 3; //設定條件一為底色紅色
//可設定之花樣有:Fonts(字型)、Borders(外框)、Interior(圖樣)

//Sheet篇
mSheet := mExcel.WorkBooks[1].WorkSheets[1];                    //將指定變數設定第一個工作表(數字可以用名稱庖代)
mSheet.Name :='內容';                                           //變動Sheet名稱
mSheet.Copy[After := mWorkBook.Sheets[mWorkBook.Sheets.Count]]; //將mSheet複製到mWorkBook最後
mSheet.Move[After := mWorkBook.Sheets[mWorkBook.Sheets.Count]]; //將mSheet搬移到mWorkBook最後
mWorkbook.Sheets.Add[After:=mWorkbook.Sheets[mSheetCount-1]];   //新增一個空白工作表
mWorkBook.Sheets[1].Delete;                                     //刪除指定Sheet
mWorkBook.Sheets[1].Activate;                                   //將指定Sheet設為利用中

mSheet.Cells[1翻譯社1].Font.Size := 10;                              //設定字體大小
mSheet.Cells[1,1].Font.Bold := True;                            //設定粗體字
......

//刪除多餘Sheet
if (mWorkBook.Sheets.Count > 1) then
begin
  for i:=2 to mWorkBook.Sheets.Count do
    mWorkBook.Sheets[2].Delete;
end;

//列印篇
mSheet.PageSetup.PrintTitleRows := '$1:$1';                      //列印題目列
mSheet.PageSetup.CenterHeader := '表頭';                         //中頁首
mSheet.PageSetup.LeftHeader   := '頁次: &P / &N';                //左頁首
mSheet.PageSetup.RightHeader  := '';                             //右頁首
mSheet.PageSetup.CenterFooter := '& &P / &N';                   //中頁尾
mSheet.PageSetup.LeftFooter   := '頁次: &P / &N';                //左頁尾
mSheet.PageSetup.RightFooter  := '';                             //右頁尾
mSheet.PageSetup.PrintArea := '$B$1:$N$300';                     //設定列印範圍
mSheet.PageSetup.Orientation := 2;                               //1.直印 2.橫印
mSheet.PageSetup.Zoom := 65;                                     //列印時小成65%
mSheet.PageSetup.Zoom := True;                                   //利用頁次縮放功能
mSheet.PageSetup.FitToPagesWide := 1;                            //縮放成一頁寬(需共同Zoom = True)
mSheet.PageSetup.FitToPagesTall := 1;                            //縮放成一頁高(需合營Zoom = True)
mSheet.PageSetup.PaperSize := 8;                                 //設定紙張巨細 8:A3、9:A4
mSheet.PageSetup.TopMargin := 1/0.035;                           //頂邊距1cm
mSheet.PageSetup.BottomMargin := 1/0.035;                        //底邊距1cm
mSheet.PageSetup.LeftMargin := 1/0.035;                          //左側距2cm
mSheet.PageSetup.RightMargin := 1/0.035;                         //右側距2cm
mSheet.PageSetup.HeaderMargin := 1/0.035;                        //頁首1cm
mSheet.PageSetup.FooterMargin := 1/0.035;                        //頁尾1cm
mSheet.PageSetup.CenterHorizontally := True;                     //頁面程度居中
mSheet.PageSetup.CenterVertically := False;                      //頁面垂直居中

//框線
mSheet.Cells[1,1].Borders[n].LineStyle := 1;
mSheet.Cells[1翻譯社1].Borders[n].Weight := 2;
//n = 5.左上右下斜線 6.左下右上斜線 7.左側線 8.上邊線 9.下邊線 10.右側線 11.垂直線 12.程度線
//Borders可以使用參數:
// LineStyle = 1 實線;-4115 短虛線;4 長短虛線;5 長短短虛線;-4118 細虛線;-4119 雙實線
// Weight =  由細到粗:1 --> 2 --> -4138 --> 4
// ColorIndex = 色彩

  花了兩天的時候把這幾年用過的 Excel VBA 指令彙總起來,分門別類,便利今後利用,隨手貼出來給有需要的朋友翻譯看倌多愛護保重啊,這可是好幾年的心血說。(使用 Delphi 語法)


//格式篇
mSheet.Range[起,迄].Merge;                                      //合併貯存格
mSheet.Cells.EntireColumn.AutoFit;                              //最適欄寬
mSheet.Cells.EntireRow.AutoFit;                                 //最適列高
mSheet.Columns[1].ColumnWidth := 100;                           //設定欄寬
mSheet.Rows[1].RowHeight := 100;                                //設定列高
mSheet.Rows[1].HorizontalAlignment := -4108;                    //水平置中(靠左:-4131;靠右:-4152)
mSheet.Rows[1].VerticalAlignment := -4108;                      //垂直置中(靠左:-4131;靠右:-4152)
mSheet.Rows[1].WrapText  := True;                               //主動換列
mSheet.Columns[1].Hidden := True;                               //隱藏

mExcel.Selection.Subtotal(1,-4157,VarArrayOf([4,5翻譯社6,7,8]),True,False翻譯社True);  //做小計
//參數說明
//      參數               中文申明         預設值
//================ ======================== ======
//GroupBy          分組小計欄位             1
//Function         使用函數                 -4157 加總
//TotalList        新增小計位置
//Replace          代替目前小計             True
//PageBreaks       每組資料分頁             False
//SummaryBelowData 摘要資料置於小計資料下方 True
//可以使用函數:-4157 加總;-4106 平均值;-4112 項目個數;-4113 數字項目數;-4136 最大值;-4139 最小值;



文章出自: http://blog.xuite.net/luckysft/blog/14509469-%E5%B8%B8%E7%94%A8+Excel+VBA+%E6%8C%87%E4%BB%A4%E5%BD%9有關翻譯的問題歡迎諮詢天成翻譯公司

arrow
arrow
    文章標籤
    翻譯社
    全站熱搜

    melanit6dw027 發表在 痞客邦 留言(0) 人氣()