自动格式化单词文档PHP,单词宏

时间:2015-04-22 01:33:03

标签: php ms-word word-vba

我有一个想法,我不确定它是否合情合理。我有一个脚本创建一个完全没有格式化的word文档,我想要做的是让它自动格式化或单击解决方案,以便用户不必浪费时间格式化它。

我的方法是我想要一个宏来跟踪创建的文档,以便下载文档的人也获得宏,他们只需单击宏来格式化文档。

这是我的单词宏

Sub FormatText()
'
' FormatText Macro
'
'
Selection.WholeStory
Selection.Font.Name = "Trebuchet MS"
Selection.Font.Size = 10
With Selection.ParagraphFormat
    .LeftIndent = CentimetersToPoints(0)
    .RightIndent = CentimetersToPoints(0)
    .SpaceBefore = 0
    .SpaceBeforeAuto = False
    .SpaceAfter = 5
    .SpaceAfterAuto = True
    .LineSpacingRule = wdLineSpaceSingle
    .Alignment = wdAlignParagraphLeft
    .WidowControl = True
    .KeepWithNext = False
    .KeepTogether = False
    .PageBreakBefore = False
    .NoLineNumber = False
    .Hyphenation = True
    .FirstLineIndent = CentimetersToPoints(0)
    .OutlineLevel = wdOutlineLevelBodyText
    .CharacterUnitLeftIndent = 0
    .CharacterUnitRightIndent = 0
    .CharacterUnitFirstLineIndent = 0
    .LineUnitBefore = 0
    .LineUnitAfter = 0
    .MirrorIndents = False
    .TextboxTightWrap = wdTightNone
End With
Selection.Font.Color = 4214888
End Sub

这是创建文档的php脚本。

<?php 
function createDoc() {
$information = "";
foreach ($_POST['docText'] as  $value) {
    $information .= $value; 
}

$file = "ProposalCredentials.doc";
file_put_contents($file, $information, LOCK_EX);
}

function download() {

$file = 'ProposalCredentials.doc';
header('Content-type: application/msword');
header('Content-length: ' .filesize($file));
header('Content-Disposition: attachment; filename='.$file);
readfile($file);
}

createDoc();
download();

?>

可以做这类事吗?
这是正确的方向吗?
或者我应该关注标题和格式吗?
或者我应该关注变量$ information并将其格式化? 或者我是否必须让每个用户在那台计算机上创建宏?(试图避免这种情况)

非常感谢正确推动。

0 个答案:

没有答案