How to copy a header with picture from one docx to an other docx - c#

I want to copy one header from a Word docx (opensml) to another Word docx.
I do it like this.
http://msdn.microsoft.com/en-us/library/cc546917.aspx
but the problem is that I have a picture in my header. Does anybody know how to get the pic copied too?

Basically you have to copy the header's relationships part, and the binary image part itself.
If the rel id doesn't change, that's all you need to do. If it does change, you'll need to update the relId in the picture XML in the header itself.

Related

Add Content menubar form in C#

I want to add content headers export from word file in this way picture in the attach
the word file included headers but i dont know how
[enter image description here(https://i.stack.imgur.com/fNxxI.png)]
I read about CH file but I cant to applied

Gembox Spreadsheet - Remove blank pages

I dont know how achieve this, I have to create an informative report with images. For this, I use an excell template (It helps me with the format and with the position of the text where to place the respective information). The images are generated perfectly. I convert this XLS to PDF with the property
DocumentToMemoryStream (excelTemplate, XlsxSaveOptions.XlsxDefault);
This report generate blank pages in the PDF. How can I remove these blank pages, before the excel is generated?
Without checking your spreadsheet it's impossible to tell from where do those empty pages come from, so can you upload your XLS?
Anyway, do you perhaps have some explicitly defined horizontal or vertical page breaks?
If yes, can you remove the ones you don't need?
Or, do you perhaps have empty columns at the end which have some kind of styling or formatting?
If yes, then you could try using something like this to remove those empty columns from exporting to PDF:
var workbook = ExcelFile.Load("input.xls");
var worksheet = workbook.Worksheets.ActiveWorksheet;
worksheet.NamedRanges.SetPrintArea(
worksheet.GetUsedCellRange(true));
var options = new PdfSaveOptions();
options.SelectionType = SelectionType.ActiveSheet;
workbook.Save("output.pdf", options);
I had a counter of the rows of the document I was writing on, thanks to the help of #Mario Z, I use this function, before the save and solve my problem of blank pages
wsimgs.NamedRanges.SetPrintArea(wsimgs.Cells.GetSubrange("A1",CellRange.RowColumnToPosition (countRow, 10)));

creating multiple txt files and directories from csv column and have the txt files filled with specific text

I have an excel file containing MANY names column and many links column, i need to create directories and text files inside them based on the excel column *. text files filled with same text inside them
Lets say i have an excel file containing column:banana,apple
The output would be Banana directory,apple directory.
Inside apple directory apple.text,inside banana directory a file called banana.text.
Inside the text files banana.text and apple.text i would like to have the same specific text WITH the links as variable inside banana.txt the same text with the apropriate link to banana in the paralel link's column and for apple.text same specific text with the appropriate link to apple in the apple link's column pls .
lets saythe text inside apple.text will looks like:
hello and nice to meet u http://apple.com
lets saythe text inside banana.text will looks like:
hello and nice to meet u http://banana.com
same words in each file just the link will be changing.
I EDITED THE QUESTION.
I think there steps needs for you.
first, automated Exccel.
https://support.microsoft.com/en-us/help/302084/how-to-automate-microsoft-excel-from-microsoft-visual-c--net
find URLs.
There is many ways for that. I recommended using Regular Expression.
find Keyword.
in URL, remove http protocal related keywords.

Tab Delimited Text Copy Paste To Excel

I am generating a block of text via C# Stringbuilder, with appropriately tab-delimited text (new lines, "\t", etc.) and displaying the text within a tag in my web application. If I copy/paste this to Excel, all the text pastes into the first column on the spreadsheet.
If I copy the outerHTML of the block (Chrome) or copy/paste into Notepad++ and THEN paste to Excel, all the data pastes neatly into individual cells - which is the desired outcome of this effort. Can anyone tell me what I need to do in order to be able to copy the text from my application and paste it into Excel, so that the text pastes into individual cells (ie, keeps the tab-delimited format)?
Unfortunately, it appears an extra step is required.
The default behaviour of paste in Excel (& many other applications) is to use the original format of the contents of the clipboard.
Copying from a web application/HTML page will result in the clipboard contents being flagged as HTML. The clipboard contents will have the tab character, but as HTML renders tabs to whitespace (compacting to a single whitespace if there are multiple tabs) - just using control-V will convert the tabs to spaces & the contents will appear in a single cell when pasting into Excel..
You will need to use the "Paste Special" option & select "Unicode text" to retain the tabs. There is no way to set this by default : https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_windows8-mso_365hp/how-to-change-default-paste-behavior-with-ctrl-v/f58da075-8fd5-4c80-a64b-5e71ec8ad38b?auth=1
Copying the outerHTML of Chrome sets the clipboard format to text in the first place, pasting to Notepad++ does paste as text rather than HTML then recopying sets the format to text - which is why these methods work.
I was able to paste to Excel and keep the format by changing the element my text wrote to from a div to textarea. Copy/paste of tsv from textarea to a tab-delimited Excel spreadsheet keeps the data formatted in tabular format when pasted. Thanks all for the help.
Try this ,
Before pasting data set excel's text to column delimiters to space and try to paste your values again.
Old topic but I had this. Need to copy something each day from a programme which outputs to google chrome browser. Whenever it was copied and pasted into excel it was going into 1 cell. Yet if I control all and paste it was ok.
I found you can copy only the lines you want and it will behave as wanted - if you don't drag the cursor all the way down off the page. ie if you highlight down to the last piece of information in the bottom right of screen more carefully, when you past to excel it pastes it as tab separated. Whereas if you drag it right down it pastes it all in 1 cell. Might help someone in the future who has this.
You can use 'text to columns' in Excel to format the data in the way you want it to.
After pasting the data into excel, select the column with your data.
Go to Data - click 'Text to columns'
Choose delimited and hit next
Choose Tab and hit finish.
If you don't want to use this extra step, the following works for Excel 2013:
Go to Home, Paste options and click 'Use text import wizard'
Choose delimited and hit next
Choose Tab and hit finish.

How to insert text & image together in single column of a table using c#?

I am trying to create a question & answer website.
Here I will save Questions & answers in a database and will retrieve them from database.
The problem is that some question & answer might have images with them. So, how do I insert text as well as images in single column of my database column?
One idea is that I will just upload images on server & will just enter url for that image with the text.
Is there any other simple way to do it ?
Referencing the images would be the easiest and best solution. You culd for example save the text using HTML and link to the images from there. Encoding the image binaries into the text would bloat the table and render things like full text search, indexing, etc. useless.
// HTML:
<img src="path/to/img.jpg" alt="Alt text">
// Markdown:
![Alt text](/path/to/img.jpg)

Categories