在C#中的页脚与输出我是一个新手,C#,我有一个“保存到文件”在我的程序选项,它可以节省一个RichTextBox的输出在一个Word文档,当用户选择这个选项,我用saveFileDialogue框为用户选择了文件名和位置。添加页眉和从我的程序
我想是每一个当用户预先选择此选项,其中输出保存Word文档有一个预先定义的页眉和页脚图片...
非常感谢你的帮助时!
下面是我的“保存到文件”的代码。
private void menuItem7_Click(object sender, EventArgs e)
{
// Create a SaveFileDialog to request a path and file name to save to.
SaveFileDialog saveFile1 = new SaveFileDialog();
// Initialize the SaveFileDialog to specify the RTF extension for the file.
saveFile1.DefaultExt = "*.rtf";
saveFile1.Filter = "RTF Files|*.rtf";
// Determine if the user selected a file name from the saveFileDialog.
if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
saveFile1.FileName.Length > 0)
{
// Save the contents of the RichTextBox into the file.
richTextBox1.SaveFile(saveFile1.FileName,
RichTextBoxStreamType.PlainText);
}
}
RichTextBox不能替代文字处理器,这是一种支持页眉和页脚的程序。您需要考虑自动化,例如Microsoft Word。在C#中得到了Microsoft.Office.Interop.Word命名空间中的类的支持。 – 2012-07-30 16:01:14
你的“页眉和页脚图片”是什么格式?像JPEG或BMP的图像?将这些保存到文本文件中不太可能有用;你想要保存文件的格式是什么? – 2012-07-30 16:03:32
如果我将文件另存为docx文件,那么我需要的更改是什么?非常感谢您的帮助! – user1563401 2012-07-30 16:04:18