質問編集履歴
3
henkou
title
CHANGED
File without changes
|
body
CHANGED
@@ -98,7 +98,7 @@
|
|
98
98
|
now_time = datetime.datetime.now()
|
99
99
|
filename = now_time.strftime('%Y_%m%d' + '.docx')
|
100
100
|
TodayDate = now_time.strftime('%Y/%m/%d')
|
101
|
-
FilePath = r'C:\Users\
|
101
|
+
FilePath = r'C:\Users\デスクトップ/'
|
102
102
|
|
103
103
|
doc = Document()
|
104
104
|
|
2
変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -111,12 +111,12 @@
|
|
111
111
|
#
|
112
112
|
# header_section.add_paragraph()
|
113
113
|
# header_text1 = header_section.paragraphs[1]
|
114
|
-
# header_text1.text = '
|
114
|
+
# header_text1.text = '名前'
|
115
115
|
# header_text1.alignment = WD_TAB_ALIGNMENT.RIGHT
|
116
116
|
|
117
117
|
# シンプルな方
|
118
118
|
ToDate = header_section.paragraphs[0]
|
119
|
-
ToDate.text = str(TodayDate) + '\n' + '
|
119
|
+
ToDate.text = str(TodayDate) + '\n' + '名前'
|
120
120
|
ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
121
121
|
|
122
122
|
# 段落に見出し追加
|
1
修正した結果
title
CHANGED
File without changes
|
body
CHANGED
@@ -85,4 +85,61 @@
|
|
85
85
|
2、ググった時のキーワード
|
86
86
|
3、解決方法を導き方
|
87
87
|
|
88
|
-
自力で解決できるようになりたいので!
|
88
|
+
自力で解決できるようになりたいので!
|
89
|
+
|
90
|
+
|
91
|
+
#教えて頂いた事を基に修正したプログラム
|
92
|
+
```Python
|
93
|
+
from docx import Document
|
94
|
+
from docx.enum.text import WD_TAB_ALIGNMENT,WD_COLOR_INDEX
|
95
|
+
|
96
|
+
import datetime
|
97
|
+
|
98
|
+
now_time = datetime.datetime.now()
|
99
|
+
filename = now_time.strftime('%Y_%m%d' + '.docx')
|
100
|
+
TodayDate = now_time.strftime('%Y/%m/%d')
|
101
|
+
FilePath = r'C:\Users\acfoa\OneDrive\デスクトップ\ResearchReport/'
|
102
|
+
|
103
|
+
doc = Document()
|
104
|
+
|
105
|
+
header_section = doc.sections[0].header
|
106
|
+
|
107
|
+
# 正式な型
|
108
|
+
# ToDate = header_section.paragraphs[0]
|
109
|
+
# ToDate.text = str(TodayDate)
|
110
|
+
# ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
111
|
+
#
|
112
|
+
# header_section.add_paragraph()
|
113
|
+
# header_text1 = header_section.paragraphs[1]
|
114
|
+
# header_text1.text = '永尾優磨'
|
115
|
+
# header_text1.alignment = WD_TAB_ALIGNMENT.RIGHT
|
116
|
+
|
117
|
+
# シンプルな方
|
118
|
+
ToDate = header_section.paragraphs[0]
|
119
|
+
ToDate.text = str(TodayDate) + '\n' + '永尾優磨'
|
120
|
+
ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
121
|
+
|
122
|
+
# 段落に見出し追加
|
123
|
+
doc.add_heading('日報', 0).alignment = WD_TAB_ALIGNMENT.CENTER
|
124
|
+
|
125
|
+
# 段落に文章追加
|
126
|
+
doc.add_heading('目的', 1)
|
127
|
+
doc.add_paragraph('')
|
128
|
+
doc.add_paragraph('')
|
129
|
+
doc.add_paragraph('')
|
130
|
+
|
131
|
+
doc.add_heading('本日の成果', 1)
|
132
|
+
doc.add_paragraph('')
|
133
|
+
doc.add_paragraph('')
|
134
|
+
doc.add_paragraph('')
|
135
|
+
|
136
|
+
doc.add_heading('課題', 1)
|
137
|
+
doc.add_paragraph('')
|
138
|
+
doc.add_paragraph('')
|
139
|
+
doc.add_paragraph('')
|
140
|
+
|
141
|
+
doc.styles["Title"].font.color.theme_color = WD_COLOR_INDEX.BLACK
|
142
|
+
doc.styles["Heading 1"].font.color.theme_color = WD_COLOR_INDEX.BLACK
|
143
|
+
|
144
|
+
doc.save(FilePath +'ss'+ filename)
|
145
|
+
```
|