小编Cin*_*ter的帖子

如何使用 python-docx 更改所有 .docx 文档的字体大小

所以,我尝试用 Python Docx 解决问题。我需要重构我的 .docx 文档,我需要更改所有文档的字体名称和字体大小。您可以建议什么解决方案?

使用此代码,字体名称会发生​​变化,但字体大小不会发生变化。

from docx import Document
from docx.shared import Pt
document = Document('path/to/file.docx')


style = document.styles['Normal']
font = style.font
font.name = 'Arial'
font.size = Pt(10)
for paragraph in document.paragraphs:
    paragraph.style = document.styles['Normal']
document.save('refactored.docx')
Run Code Online (Sandbox Code Playgroud)

python xml ms-word python-3.x python-docx

1
推荐指数
1
解决办法
3864
查看次数

C中的链接列表,无法插入和显示节点

我尝试实现链接列表,但无法找出未显示预期结果的实际错误所在?我试图通过随机放置在printfs可疑位置来跟踪程序的控制流。

我试图跟踪该控件,并意识到在插入第一个节点之后,所做的更改不会反映在原始链表中。回到main()链接列表后,再次为空!

#include<stdio.h>
#include<stdlib.h>

struct node
{
    int data;
    struct node *link;
};

int count(struct node *q);
void append(struct node *q, int item);
void display(struct node *q);
void add_after(struct node *q, int item, int pos);
void add_beg(struct node *q, int item);
int delete(struct node *q);

int main()
{
    struct node *p = NULL;
    int item,count,i;

    printf("Enter the element to insert\n");
    scanf("%d",&item);

    append(p,item);

    printf("Control\n");
    printf("%d",p);

    display(p);


    //printf("No. of elements in Linked list = %d",count(p));

    // printf("Enter number …
Run Code Online (Sandbox Code Playgroud)

c function linked-list definition singly-linked-list

1
推荐指数
1
解决办法
119
查看次数

VBA Word - Apply a style to a line of text

I'm trying to apply a word style to a line of text using vba, so that it will appear in the table of contents. I am having trouble keeping the style contained to the line in question though, for some reason the whole document is picking up the style.

With Selection
.TypeText Text:=headername                 ' This is defined previously,
.HomeKey Unit:=wdLine, Extend:=wdMove   ' This is to move the cursor to the start of the line
.Expand wdLine                           ' This is to …
Run Code Online (Sandbox Code Playgroud)

vba ms-word word-style

0
推荐指数
1
解决办法
8991
查看次数

如何解决VB6中的"编译错误:类型不匹配"错误?

似乎已经有一些答案,但我找不到适合我的问题的答案.

这是代码:

Private Sub Combo2_click()
Dim item_id, price As Integer
Dim item_name As String
If Combo2.Index Is 0 Then
    price = 30
ElseIf Combo2.Index Is 1 Then
    price = 40
ElseIf Combo2.Index Is 2 Then
    price = 50
ElseIf Combo2.Index Is 3 Then
    price = 60
Else
    price = 55
End If
End Sub
Run Code Online (Sandbox Code Playgroud)

我收到错误"编译错误:输入MisMatch"...我不知道为什么!它显示错误Private Sub COmbo2_click()...

vb6

0
推荐指数
1
解决办法
1001
查看次数

c ++类输出不完全显示

此代码不会产生任何错误,但在输出中只显示此行,然后程序退出:

cout << "write 1 for areaoftrapezium and 2 for areaofrhombus and 3 for                      areaofParallelogram " << endl;
cin >> option;
Run Code Online (Sandbox Code Playgroud)

这里的完整代码我不知道出了什么问题

#include<iostream>
using namespace std;

 class project
{

private:
float base, base2, height;
float diagonal, diagonal2;
float base3, aldtude;
  public:
void trapezium() {

    float areaoftrapezium;
    areaoftrapezium = 0.5*(base + base2)*height;
    cout << "the area of trapezium is:" << areaoftrapezium;
  }
void rhombus() {

    float areaofrhombus;
    areaofrhombus = 0.5*diagonal*diagonal2;
    cout << "the  area of rhombus is:" << areaofrhombus;
}
void …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
31
查看次数

使用 Python 访问打开的 Excel 工作簿

如何使用win32com模块找到打开的 Excel 工作簿?我只想读取尚未保存的 Excel 工作簿中的单元格。或者有什么文件可以参考吗?

python excel python-module win32com openpyxl

0
推荐指数
1
解决办法
1916
查看次数

如何知道光标/选择是否在空行上?

我目前正在努力解决一个非常简单的问题。对于宏,我想知道我的光标是否在空行上。我想使用Len()orCount但它们总是返回1(即使当前行有更多字符)。

我认为使用 aRange而不是Selection可以有所帮助,但我不知道该怎么做(我对 vba-word 不是很熟练)。我想我可以选择整条线(如何?),但if Selection.Characters.Count > 1 Then [...]它看起来丑陋且效率低下。

预先感谢您的任何帮助或建议,

vba ms-word

0
推荐指数
1
解决办法
2529
查看次数

如何使用openxml合并具有不同标题的word文档?

我正在尝试按照另一篇文章中发布的示例将多个文档合并为一个文档。\n我正在使用AltChunk altChunk = new AltChunk(). 当文档被合并时,它似乎并没有保留每个文档的单独的听众。合并后的文档将包含合并期间第一个文档的标题。如果要合并的第一个文档不包含听者,则新合并文档的所有其余部分将不包含标题,反之亦然。

\n\n

我的问题是,如何保留正在合并的文档的不同标题?

\n\n

将多个 Word 文档合并为一个 Open Xml

\n\n
using System;\nusing System.IO;\nusing System.Linq;\nusing DocumentFormat.OpenXml.Packaging;\nusing DocumentFormat.OpenXml.Wordprocessing;\n\nnamespace WordMergeProject\n{\n    public class Program\n    {\n        private static void Main(string[] args)\n        {\n            byte[] word1 = File.ReadAllBytes(@"..\\..\\word1.docx");\n            byte[] word2 = File.ReadAllBytes(@"..\\..\\word2.docx");\n\n            byte[] result = Merge(word1, word2);\n\n            File.WriteAllBytes(@"..\\..\\word3.docx", result);\n        }\n\n        private static byte[] Merge(byte[] dest, byte[] src)\n        {\n            string altChunkId = "AltChunkId" + DateTime.Now.Ticks.ToString();\n\n            var memoryStreamDest = new MemoryStream();\n            memoryStreamDest.Write(dest, 0, dest.Length);\n            memoryStreamDest.Seek(0, SeekOrigin.Begin);\n            var memoryStreamSrc = new MemoryStream(src);\n\n            using …
Run Code Online (Sandbox Code Playgroud)

ms-word openxml openxml-sdk

0
推荐指数
1
解决办法
3337
查看次数

带有软件包的Java 9 Modularity

假设我有2个模块:

  • module1有包 package1

  • module2有package2,package3package4

我希望package1package2在module2中可见.不到module2中的任何其他包(package3package4).

这可能使用module-info.java吗?

java modularity module java-9

-1
推荐指数
1
解决办法
63
查看次数

避免在 URLComponents 中对主机进行百分比编码

使用URLComponents,有没有办法避免主机的百分比编码?

var components = URLComponents()
components.scheme = "https"
components.host = "endpoint.com/v1/api.php?"
// ends up as https://endpoint.com%2Fv1%2Fapi.php%3F? but I want it to stay as https://endpoint.com/v1/api.php?
Run Code Online (Sandbox Code Playgroud)

这个问题是关于避免编码,而不是添加编码作为作为重复状态链接的问题。

ios swift nsurlcomponents

-1
推荐指数
1
解决办法
487
查看次数

有没有使用case语句存储存储文件的简单方法?

我正在尝试创建代码来检查名称列。我想将文件分类为三类(名称分别在AG,HP,QZ之间)。

在保存文件之前,我想出了一个案例说明是正确的方法,但是不确定是否需要利用instr函数或类似的东西。

这是我目前如何设置的一个粗略示例(注释了case语句)。

        Dim BASEPATH_1 As String, BASEPATH_2 As String, BASEPATH_3 As String


        BASEPATH_1 = "C:\Users\A-G\"
        BASEPATH_2 = "C:\Users\H-P\"
        BASEPATH_3 = "C:\Users\Q-Z\"


        Select Case wb.Cells(i, 8)
        'Case i.value is betwen "A-G"
            wb.SaveCopyAs BASEPATH_1 & _
            ValidFileName(Login & "_" & Last & "_PrePlanning File.xlsx")
        'Case i.value is betwen "H-P"
            wb.SaveCopyAs BASEPATH_2 & _
            ValidFileName(Login & "_" & Last & "_PrePlanning File.xlsx")
        'Case i.value is betwen "Q-Z"
            wb.SaveCopyAs BASEPATH_3 & _
            ValidFileName(Login & "_" & Last & "_PrePlanning File.xlsx")
        Case …
Run Code Online (Sandbox Code Playgroud)

excel vba

-1
推荐指数
1
解决办法
48
查看次数