PDA

View Full Version : سوال: خواندن اطلاعات از sql و درج در فایل docx فرمت دهی شده



parnian man
چهارشنبه 04 بهمن 1391, 07:12 صبح
وقت بخیر

من یه فایل docx دارم که فرمت دهی شده است یعنی اینکه دارای جدول و هدر و ... هست
میخوام اطلاعات و از دیتابیس بخونم و در سطر و ستون مورد نظرم در جدولی از این فایل درج کنم

از چه dll هایی برای این کار می شه استفاده کرد؟
لطفا معرفی کنید ممنون می شم

havash.link
چهارشنبه 04 بهمن 1391, 10:56 صبح
منم همچین مشکلی واسم پیش امده
از اساتید محترم خواهش می کنم راهنمایی بکنن

sohil_ww
چهارشنبه 04 بهمن 1391, 16:31 عصر
تو تایپیکای قبلی یکی از دوستان کامل توضیح دادن http://barnamenevis.org/showthread.php?378495-%D8%B3%D8%A7%D8%AE%D8%AA-%DA%AF%D8%B2%D8%A7%D8%B1%D8%B4-%D8%A8%D8%A7-Word

havash.link
جمعه 06 بهمن 1391, 08:02 صبح
تو تایپیکای قبلی یکی از دوستان کامل توضیح دادن http://barnamenevis.org/showthread.php?378495-%D8%B3%D8%A7%D8%AE%D8%AA-%DA%AF%D8%B2%D8%A7%D8%B1%D8%B4-%D8%A8%D8%A7-Word


دوست عزیز تو این تاپیک انتقال از database به word هستش
سوال ما برعکس این قضیه هستش یعنی ازword به database

parnian man
شنبه 07 بهمن 1391, 11:15 صبح
ممنون از لینکی که فرستادین

برنامه رو کامل کردم و روی لوکال با وِیژوال استودیو که اجرا میشه همه چی اوکیه اما وقتی ست آپ می سازم و با iis اجرا می کنم خطای زیر و میده


System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00020906-0000-0000-C000-000000000046} failed due to the following error: 80080005.


افیسی که رو سیستمم نصبه 2010 و ویندوزم xp 32bit و ویژوال استودی 2010 و دی ال ال که add می کنم هم microsoft word 14.0 object library هست

parnian man
دوشنبه 09 بهمن 1391, 18:31 عصر
خطایی که میداد برطرف شده ولی وقتی روی لینکی که فایل word و تولید میکنه کلیک می کنم صفحه دوباره لود می شه و هیچ اتفاقی نمی افته
مشکل کجاست؟؟؟؟؟

khokhan
دوشنبه 09 بهمن 1391, 19:03 عصر
خطایی که میداد برطرف شده ولی وقتی روی لینکی که فایل word و تولید میکنه کلیک می کنم صفحه دوباره لود می شه و هیچ اتفاقی نمی افته
مشکل کجاست؟؟؟؟؟

سلام

اینطوری نمی شه چیزی گفت

اگه ممکنه سورس برنامه تونو بگذارین

parnian man
پنج شنبه 12 بهمن 1391, 18:53 عصر
Object oMissing = System.Reflection.Missing.Value;

Object oTrue = true;
Object oFalse = false;

Word.Application oWord = new Word.Application();
Word.Document oWordDoc = new Word.Document();


oWord.Visible = true;

try
{
Object oTemplatePath = Server.MapPath("\\shenasname.dotx");

oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);

foreach (Word.Field myMergeField in oWordDoc.Fields)
{

Word.Range rngFieldCode = myMergeField.Code;
String fieldText = rngFieldCode.Text;

if (fieldText.StartsWith(" MERGEFIELD"))
{

Int32 endMerge = fieldText.IndexOf("\\");
Int32 fieldNameLength = fieldText.Length - endMerge;
String fieldName = fieldText.Substring(11, endMerge - 11);

fieldName = fieldName.Trim();
if (fieldName == "ComputerName")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[1].Text);
}

if (fieldName == "IP")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[2].Text);
}

if (fieldName == "PrizNum")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[23].Text);
}

if (fieldName == "SwitchNum")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[24].Text);
}

if (fieldName == "PatchNum")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[25].Text);
}

if (fieldName == "MouseNum")
{
myMergeField.Select();
oWord.Selection.TypeText(" ");
}

if (fieldName == "SpeakerNum")
{
myMergeField.Select();
oWord.Selection.TypeText(" ");
}

if (fieldName == "KeyboardNum")
{
myMergeField.Select();
oWord.Selection.TypeText(" ");
}

if (fieldName == "MonitorNum")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[27].Text);
}

if (fieldName == "CaseNum")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[26].Text);
}


string mainuser = null;
string user = null;
for (int i = 0; i < grdpeigiri.Rows.Count; i++)
{
if (grdpeigiri.Rows[i].Cells[5].Text.Contains("*"))
{
mainuser = grdpeigiri.Rows[i].Cells[4].Text;
}
else
{
if (user == null)
{
user = user + grdpeigiri.Rows[i].Cells[4].Text;
}
else
{
user = user + " - " + grdpeigiri.Rows[i].Cells[4].Text;
}
}
}
if (user == null) user = "-";
if (fieldName == "Section")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[7].Text);
}

if (fieldName == "MainUser")
{
myMergeField.Select();
oWord.Selection.TypeText(mainuser);
}

if (fieldName == "OtherUser")
{
myMergeField.Select();
oWord.Selection.TypeText(user);
}

if (fieldName == "MainBoard")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[18].Text);
}

if (fieldName == "CPU")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[10].Text);
}

if (fieldName == "RAM")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[11].Text);
}

if (fieldName == "HDD")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[13].Text);
}

if (fieldName == "VGA")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[12].Text);
}

if (fieldName == "Sound")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[20].Text);
}

if (fieldName == "Lan")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[19].Text);
}

if (fieldName == "Case")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[8].Text);
}

if (fieldName == "Monitor")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[9].Text);
}

if (fieldName == "ODD")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[21].Text);
}

if (fieldName == "Scanner")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[15].Text);
}

if (fieldName == "Speaker")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[16].Text);
}

if (fieldName == "Modem")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[22].Text);
}

if (fieldName == "UPS")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[17].Text);
}

if (fieldName == "Printer")
{
myMergeField.Select();
oWord.Selection.TypeText(grdpeigiri.Rows[RowIndex].Cells[14].Text);
}
}
}
}
catch
{

}
}