1/**//// <summary>
2 /// 1.Clear CircleReference
3 /// 2.Set Page to Fit Wide
4 /// 3.Set Column Text fit
5 /// </summary>
6 /// <param name="app"></param>
7 /// <param name="ws"></param>
8 private void WorkSheetPageSet(Microsoft.Office.Interop.Excel.Application app, Worksheet ws)
9 {
10 ClearCircleReference(ws);
11
12 SetPagetoFitWide(ws);
13
14 SetColumnFit(ws);
15 }
16
17 /**//// <summary>
18 /// Set Column Text fit
19 /// </summary>
20 /// <param name="sheet"></param>
21 private static void SetColumnFit(Worksheet sheet)
22 {
23 char column = B;
24 for (int i = 0; i < 25; i++)
25 {
26
27 Range range = sheet.get_Range(String.Format("{0}1", column.ToString()),
28 String.Format("{0}1", column.ToString()));
29 if (range != null)
30 {
31 range.EntireColumn.AutoFit();
32 }
33 column++;
34 }
35 }
36
37 /**//// <summary>
38 /// Clear CircleReference
39 /// </summary>
40 /// <param name="sheet">Worksheet object</param>
41 private void ClearCircleReference(Worksheet sheet)
42 {
43 Range range = sheet.CircularReference;
44 while (range != null)
45 {
46 range.Clear();
47 range = sheet.CircularReference;
48 }
49 }
50
51 /**//// <summary>
52 /// Set Page to Fit Wide
53 /// </summary>
54 /// <param name="ws">Worksheet object</param>
55 private static void SetPagetoFitWide(Worksheet ws)
56 {
57 ws.PageSetup.Zoom = false;
58 ws.PageSetup.FitToPagesWide = 1;
59 ws.PageSetup.FitToPagesTall = false;
60 }