please hav a look to below code....
view plaincopy to clipboardprint?
.................div data...................
| Vikas:Ji |
|---|
| Vikas:Ji |
| Vikas: |
| Vikas: |
..............to write dive data into word file
public void PrintControl()
{
try
{
String strr = printdiv.InnerHtml;
string strPath = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
FileStream fStream = File.Create(strPath);
fStream.Close();
StreamWriter sWriter = new StreamWriter(strPath);
sWriter.Write(strr);
sWriter.Close();
edit_changes();
}
catch (Exception err)
{
//error.Text = err.Message;
}
}
.........................To format the word file...set left and top margin.........................
private void edit_changes()
{
Object missing = System.Reflection.Missing.Value;
Object fileName = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.Document(); ;
Object;
// oDoc.Close(ref missing, ref missing, ref missing);
if (File.Exists((String)fileName))
{
DateTime today = DateTime.Now;
Object isVisible = false;
wordApp.Visible = false;
oDoc = wordApp.Documents.Open(ref fileName, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
isVisible, ref missing, ref missing, ref missing, ref missing);
oDoc.Activate();
oDoc.PageSetup.TopMargin = 150.0f;
oDoc.PageSetup.BottomMargin = 200.0f;
}
object Background = true;
object Range = Word.WdPrintOutRange.wdPrintAllDocument;
object Copies = 2;
object PageType = Word.WdPrintOutPages.wdPrintAllPages;
object PrintToFile = false;
object Collate = false;
object ActivePrinterMacGX = missing;
object ManualDuplexPrint = false;
object PrintZoomColumn = 1;
object PrintZoomRow = 1;
oDoc.Close(ref missing, ref missing, ref missing);
oDoc.PrintOut(ref Background, ref missing, ref Range, ref missing,
ref missing, ref missing, ref missing, ref Copies,
ref missing, ref PageType, ref PrintToFile, ref Collate,
ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
ref PrintZoomRow, ref missing, ref missing);
CrishPosted Dec 13, 2010, 6:05 AM
I have same problem thanks for this code it will help me to solve my issue of printout() function.