.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

prinout function problem()

Posted By: vikas     Posted Date: August 25, 2010    Points:2   Category :ASP.Net
i m using below code..by using it i able to write asp data into word file n format it.but i m facing problen in print out..

please hav a look to below code....

view plaincopy to clipboardprint?
.................div data...................
<div id="printdiv" runat="server">
<table style="border: 5px solid #FF00FF; width:100%">
<tr>
<th align="left" style="background-color: #00FFFF">Vikas:Ji</th>
</tr>
<tr>
<th align="right" style="background-color: #800000">Vikas:Ji</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</div>


..............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);



Responses
Author: Narayanan             
Posted Date: October 24, 2011     Points: 20   

hi,
Please mentioned your error..

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Ravi Ranjan Kumar             
Posted Date: October 28, 2011     Points: 20   

dear vikas be more specific while asking question we need more information about your question instead of trash code. I hope you will revert back here with specific question.

Thank You


Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend