質問編集履歴
3
henkou
test
CHANGED
File without changes
|
test
CHANGED
@@ -198,7 +198,7 @@
|
|
198
198
|
|
199
199
|
TodayDate = now_time.strftime('%Y/%m/%d')
|
200
200
|
|
201
|
-
FilePath = r'C:\Users\
|
201
|
+
FilePath = r'C:\Users\デスクトップ/'
|
202
202
|
|
203
203
|
|
204
204
|
|
2
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -224,7 +224,7 @@
|
|
224
224
|
|
225
225
|
# header_text1 = header_section.paragraphs[1]
|
226
226
|
|
227
|
-
# header_text1.text = '
|
227
|
+
# header_text1.text = '名前'
|
228
228
|
|
229
229
|
# header_text1.alignment = WD_TAB_ALIGNMENT.RIGHT
|
230
230
|
|
@@ -234,7 +234,7 @@
|
|
234
234
|
|
235
235
|
ToDate = header_section.paragraphs[0]
|
236
236
|
|
237
|
-
ToDate.text = str(TodayDate) + '\n' + '
|
237
|
+
ToDate.text = str(TodayDate) + '\n' + '名前'
|
238
238
|
|
239
239
|
ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
240
240
|
|
1
修正した結果
test
CHANGED
File without changes
|
test
CHANGED
@@ -173,3 +173,117 @@
|
|
173
173
|
|
174
174
|
|
175
175
|
自力で解決できるようになりたいので!
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
#教えて頂いた事を基に修正したプログラム
|
182
|
+
|
183
|
+
```Python
|
184
|
+
|
185
|
+
from docx import Document
|
186
|
+
|
187
|
+
from docx.enum.text import WD_TAB_ALIGNMENT,WD_COLOR_INDEX
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
import datetime
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
now_time = datetime.datetime.now()
|
196
|
+
|
197
|
+
filename = now_time.strftime('%Y_%m%d' + '.docx')
|
198
|
+
|
199
|
+
TodayDate = now_time.strftime('%Y/%m/%d')
|
200
|
+
|
201
|
+
FilePath = r'C:\Users\acfoa\OneDrive\デスクトップ\ResearchReport/'
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
doc = Document()
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
header_section = doc.sections[0].header
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
# 正式な型
|
214
|
+
|
215
|
+
# ToDate = header_section.paragraphs[0]
|
216
|
+
|
217
|
+
# ToDate.text = str(TodayDate)
|
218
|
+
|
219
|
+
# ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
220
|
+
|
221
|
+
#
|
222
|
+
|
223
|
+
# header_section.add_paragraph()
|
224
|
+
|
225
|
+
# header_text1 = header_section.paragraphs[1]
|
226
|
+
|
227
|
+
# header_text1.text = '永尾優磨'
|
228
|
+
|
229
|
+
# header_text1.alignment = WD_TAB_ALIGNMENT.RIGHT
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
# シンプルな方
|
234
|
+
|
235
|
+
ToDate = header_section.paragraphs[0]
|
236
|
+
|
237
|
+
ToDate.text = str(TodayDate) + '\n' + '永尾優磨'
|
238
|
+
|
239
|
+
ToDate.alignment = WD_TAB_ALIGNMENT.RIGHT
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# 段落に見出し追加
|
244
|
+
|
245
|
+
doc.add_heading('日報', 0).alignment = WD_TAB_ALIGNMENT.CENTER
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
# 段落に文章追加
|
250
|
+
|
251
|
+
doc.add_heading('目的', 1)
|
252
|
+
|
253
|
+
doc.add_paragraph('')
|
254
|
+
|
255
|
+
doc.add_paragraph('')
|
256
|
+
|
257
|
+
doc.add_paragraph('')
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
doc.add_heading('本日の成果', 1)
|
262
|
+
|
263
|
+
doc.add_paragraph('')
|
264
|
+
|
265
|
+
doc.add_paragraph('')
|
266
|
+
|
267
|
+
doc.add_paragraph('')
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
doc.add_heading('課題', 1)
|
272
|
+
|
273
|
+
doc.add_paragraph('')
|
274
|
+
|
275
|
+
doc.add_paragraph('')
|
276
|
+
|
277
|
+
doc.add_paragraph('')
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
doc.styles["Title"].font.color.theme_color = WD_COLOR_INDEX.BLACK
|
282
|
+
|
283
|
+
doc.styles["Heading 1"].font.color.theme_color = WD_COLOR_INDEX.BLACK
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
doc.save(FilePath +'ss'+ filename)
|
288
|
+
|
289
|
+
```
|